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::
17 * Lilypond-book templates::
23 @subsection 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 @subsection 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 @subsection 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 @subsection 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
149 \midi { \tempo 4=60 }
153 @node Piano templates
154 @section Piano templates
155 @subsection 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.instrument = "Piano "
180 \new Staff = "upper" \upper
181 \new Staff = "lower" \lower
184 \midi { \tempo 4=60 }
188 @subsection 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 }
239 \midi { \tempo 4=60 }
244 @subsection 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" }
284 \midi { \tempo 4=60 }
289 @subsection 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 @section String quartet
388 @subsection 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.instrument = "Violin 1 "
407 violinTwo = \new Voice { \relative c''{
408 \set Staff.instrument = "Violin 2 "
413 viola = \new Voice { \relative c' {
414 \set Staff.instrument = "Viola "
420 cello = \new Voice { \relative c' {
421 \set Staff.instrument = "Cello "
430 \new Staff << \global \violinOne >>
431 \new Staff << \global \violinTwo >>
432 \new Staff << \global \viola >>
433 \new Staff << \global \cello >>
440 @subsection 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.instrument = "Violin 1 "
466 \bar "|." }} %*********************************
467 Violintwo = \new Voice { \relative c''{
468 \set Staff.instrument = "Violin 2 "
472 \bar "|." }} %*********************************
473 Viola = \new Voice { \relative c' {
474 \set Staff.instrument = "Viola "
479 \bar "|." }} %*********************************
480 Cello = \new Voice { \relative c' {
481 \set Staff.instrument = "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
506 \midi { \tempo 4 = 60 }
514 \keepWithTag #'vn1 \music
523 \keepWithTag #'vn2 \music
532 \keepWithTag #'vla \music
541 \keepWithTag #'vlc \music
547 @node Vocal ensembles
548 @section Vocal ensembles
550 @subsection 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 @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,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)
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
960 @subsection Gregorian transcription template
962 This example demonstrates how to do modern transcriptions of Gregorian
963 music. Gregorian music has no measure, no stems; it uses only half and
964 quarter notes, and two types of barlines, a short one indicating a rest,
965 and a second one indicating a breath mark.
967 @lilypond[quote,verbatim,ragged-right]
968 \include "gregorian-init.ly"
971 chant = \relative c' {
972 \set Score.timing = ##f
974 g4 b a2 f2 \divisioMaior
975 g4( f) f( g) a2 \finalis
979 Lo -- rem ip -- sum do -- lor sit a -- met
984 \new Voice = "melody" {
987 \new Lyrics = "one" \lyricsto melody \verba
993 \remove "Time_signature_engraver"
994 \remove "Bar_engraver"
995 \override Stem #'transparent = ##t
999 \override Stem #'length = #0
1013 This is a much more complicated template, for a jazz ensemble. Note that all
1014 instruments are notated in @code{\key c \major}. This refers to the key in
1015 concert pitch; LilyPond will automatically transpose the key if the music
1016 is within a @code{\transpose} section.
1018 @c TODO must clean up this jazz combo example
1019 @c - transpositions stated in names (ie "trumpet in Bb" or whatever)
1020 @c - one global section, instead of "global" (time) and "key"
1021 @c - does it need those wierd macros? sl, nsl, etc.
1022 @c - maybe ask Amelie Zapf to clean it up, or whether I should just
1023 @c make whatever changes I feel like.
1025 @c FIXME: produces a warning ; key change merge.
1026 @c The `line-width' argument is for the \header.
1028 @lilypond[quote,verbatim,ragged-right,line-width]
1036 tagline = "LilyPond example file by Amelie Zapf,
1038 texidoc = "Jazz tune for combo
1039 (horns, guitar, piano, bass, drums)."
1042 #(set-global-staff-size 16)
1043 \include "english.ly"
1045 %%%%%%%%%%%% Some macros %%%%%%%%%%%%%%%%%%%
1048 \override NoteHead #'style = #'slash
1049 \override Stem #'transparent = ##t
1052 \revert NoteHead #'style
1053 \revert Stem #'transparent
1055 cr = \override NoteHead #'style = #'cross
1056 ncr = \revert NoteHead #'style
1058 %% insert chord name style stuff here.
1063 %%%%%%%%%%%% Keys'n'thangs %%%%%%%%%%%%%%%%%
1069 Key = { \key c \major }
1071 % ############ Horns ############
1073 % ------ Trumpet ------
1074 trpt = \transpose c d \relative c'' {
1078 trpharmony = \transpose c' d {
1083 \set Staff.instrument = #"Trumpet"
1090 % ------ Alto Saxophone ------
1091 alto = \transpose c a \relative c' {
1095 altoharmony = \transpose c' a {
1100 \set Staff.instrument = #"Alto Sax"
1107 % ------ Baritone Saxophone ------
1108 bari = \transpose c a' \relative c {
1110 c1 c \sl d4^"Solo" d d d \nsl
1112 bariharmony = \transpose c' a \chordmode {
1113 \jzchords s1 s d2:maj e:m7
1117 \set Staff.instrument = #"Bari Sax"
1124 % ------ Trombone ------
1125 tbone = \relative c {
1129 tboneharmony = \chordmode {
1134 \set Staff.instrument = #"Trombone"
1141 % ############ Rhythm Section #############
1143 % ------ Guitar ------
1144 gtr = \relative c'' {
1146 c1 \sl b4 b b b \nsl c1
1148 gtrharmony = \chordmode {
1154 \set Staff.instrument = #"Guitar"
1161 %% ------ Piano ------
1162 rhUpper = \relative c'' {
1167 rhLower = \relative c' {
1173 lhUpper = \relative c' {
1178 lhLower = \relative c {
1187 \set Staff.midiInstrument = "acoustic grand"
1189 \new Voice = "one" \rhUpper
1190 \new Voice = "two" \rhLower
1196 \set Staff.midiInstrument = "acoustic grand"
1198 \new Voice = "one" \lhUpper
1199 \new Voice = "two" \lhLower
1205 \set PianoStaff.instrument = #"Piano"
1206 \new Staff = "upper" \PianoRH
1207 \new Staff = "lower" \PianoLH
1211 % ------ Bass Guitar ------
1212 Bass = \relative c {
1218 \set Staff.instrument = #"Bass"
1225 % ------ Drums ------
1227 hh4 <hh sn>4 hh <hh sn> hh <hh sn>4
1234 bd4 s bd s bd s bd s bd s bd s
1240 \set DrumStaff.instrument = #"Drums"
1241 \new DrumVoice { \voiceOne \up }
1242 \new DrumVoice { \voiceTwo \down }
1246 %%%%%%%%% It All Goes Together Here %%%%%%%%%%%%%%%%%%%%%%
1250 \new StaffGroup = "horns" <<
1251 \new Staff = "trumpet" \trumpet
1252 \new Staff = "altosax" \altosax
1253 \new ChordNames = "barichords" \bariharmony
1254 \new Staff = "barisax" \barisax
1255 \new Staff = "trombone" \trombone
1258 \new StaffGroup = "rhythm" <<
1259 \new ChordNames = "chords" \gtrharmony
1260 \new Staff = "guitar" \guitar
1261 \new PianoStaff = "piano" \piano
1262 \new Staff = "bass" \bass
1263 \new DrumStaff { \drumContents }
1268 \context { \RemoveEmptyStaffContext }
1271 \override BarNumber #'padding = #3
1272 \override RehearsalMark #'padding = #2
1277 \midi { \tempo 4 = 75 }
1283 This isn't very useful, and only duplicates material in
1284 "global issues". And if this info changes, this section often
1287 @no de Other templates
1288 @se ction Other templates
1289 @su bsection All headers
1291 This template displays all available headers. Some of them are only
1292 used in the Mutopia project; they don't affect the printed output at
1293 all. They are used if you want the piece to be listed with different
1294 information in the Mutopia database than you wish to have printed on the
1295 music. For example, Mutopia lists the composer of the famous D major
1296 violin concerto as TchaikovskyPI, whereas perhaps you wish to print
1297 "Petr Tchaikowski" on your music.
1299 @ The `line-width' is for \header.
1300 @li lypond[quote,verbatim,ragged-right,line-width]
1303 dedication = "dedication"
1305 subtitle = "Subtitle"
1306 subsubtitle = "Subsubtitle"
1307 composer = "Composer (xxxx-yyyy)"
1311 instrument = "Instrument"
1312 arranger = "Arranger"
1314 texttranslator = "Translator"
1315 copyright = "public domain"
1317 % These are headers used by the Mutopia Project
1318 % http://www.mutopiaproject.org/
1320 mutopiacomposer = ""
1322 mutopiainstrument = ""
1323 date = "composer's dates"
1325 maintainer = "your name here"
1326 maintainerEmail = "your email here"
1327 maintainerWeb = "your home page"
1328 lastupdated = "2004/Aug/26"
1350 @node Lilypond-book templates
1351 @section Lilypond-book templates
1353 These templates are for use with @code{lilypond-book}. If you're not familiar
1354 with this program, please refer to @ref{LilyPond-book}.
1358 You can include LilyPond fragments in a LaTeX document.
1361 \documentclass[]@{article@}
1385 You can include LilyPond fragments in Texinfo; in fact, this entire manual
1386 is written in Texinfo.
1394 @@lilypond[verbatim,fragment,ragged-right]
1400 @@lilypond[verbatim,fragment,ragged-right]