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 \new 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 >>
718 % a little smaller so lyrics
719 % can be closer to the staff
721 \override VerticalAxisGroup #'minimum-Y-extent = #'(-3 . 3)
728 @c bad node name to avoid node name confict
729 @node Ancient notation templates
730 @section Ancient notation templates
732 @subsection Transcription of mensural music
734 When transcribing mensural music, an incipit at the beginning of the
735 piece is useful to indicate the original key and tempo. While today
736 musicians are used to bar lines in order to faster recognize rhythmic
737 patterns, bar lines were not yet invented during the period of
738 mensural music; in fact, the meter often changed after every few
739 notes. As a compromise, bar lines are often printed between the
740 staves rather than on the staves.
742 @lilypond[quote,verbatim,line-width=11.0\cm]
746 \set Score.skipBars = ##t
749 \once \override Score.SystemStartBracket #'transparent = ##t
750 \override Score.SpacingSpanner #'spacing-increment = #1.0 % tight spacing
753 \once \override Staff.TimeSignature #'style = #'neomensural
754 \override Voice.NoteHead #'style = #'neomensural
755 \override Voice.Rest #'style = #'neomensural
756 \set Staff.printKeyCancellation = ##f
757 \cadenzaOn % turn off bar lines
759 \once \override Staff.BarLine #'transparent = ##f
761 \skip 1*1 % need this extra \skip such that clef change comes
766 \revert Score.SpacingSpanner #'spacing-increment % CHECK: no effect?
767 \cadenzaOff % turn bar lines on again
768 \once \override Staff.Clef #'full-size-change = ##t
769 \set Staff.forceClef = ##t
772 \override Voice.NoteHead #'style = #'default
773 \override Voice.Rest #'style = #'default
775 % FIXME: setting printKeyCancellation back to #t must not
776 % occur in the first bar after the incipit. Dto. for forceClef.
777 % Therefore, we need an extra \skip.
779 \set Staff.printKeyCancellation = ##t
780 \set Staff.forceClef = ##f
782 \skip 1*7 % the actual music
784 % let finis bar go through all staves
785 \override Staff.BarLine #'transparent = ##f
793 \set Staff.instrument = "Discantus "
796 \clef "neomensural-c1"
798 \skip 1*8 % eight bars
808 \once \override NoteHead #'transparent = ##t c'1 |
813 discantusLyrics = \lyricmode {
829 \set Staff.instrument = "Altus "
832 \clef "neomensural-c3"
835 \skip 1*7 % seven bars
840 r2 g2. e4 fis g | % two bars
842 fis g4.( fis16 e fis4) |
844 \once \override NoteHead #'transparent = ##t g1 |
849 altusLyrics = \lyricmode {
854 Ju -- bi -- la -- te | % two bars
863 \set Staff.instrument = "Tenor "
866 \clef "neomensural-c4"
879 r2 d'2. d'4 b e' | % two bars
880 \once \override NoteHead #'transparent = ##t e'1 |
885 tenorLyrics = \lyricmode {
890 Ju -- bi -- la -- te | % two bars
897 \set Staff.instrument = "Bassus "
901 r\maxima % eight bars
912 \once \override NoteHead #'transparent = ##t e1 |
917 bassusLyrics = \lyricmode {
928 \new StaffGroup = choirStaff <<
930 "discantusNotes" << \global \discantusNotes >>
932 "discantusLyrics" \lyricsto discantusNotes { \discantusLyrics }
934 "altusNotes" << \global \altusNotes >>
936 "altusLyrics" \lyricsto altusNotes { \altusLyrics }
938 "tenorNotes" << \global \tenorNotes >>
940 "tenorLyrics" \lyricsto tenorNotes { \tenorLyrics }
942 "bassusNotes" << \global \bassusNotes >>
944 "bassusLyrics" \lyricsto bassusNotes { \bassusLyrics }
949 \override BarLine #'transparent = ##t
950 \remove "System_start_delimiter_engraver"
954 \override Slur #'transparent = ##t
965 This is a much more complicated template, for a jazz ensemble. Note that all
966 instruments are notated in @code{\key c \major}. This refers to the key in
967 concert pitch; LilyPond will automatically transpose the key if the music
968 is within a @code{\transpose} section.
970 @c TODO must clean up this jazz combo example
971 @c - transpositions stated in names (ie "trumpet in Bb" or whatever)
972 @c - one global section, instead of "global" (time) and "key"
973 @c - does it need those wierd macros? sl, nsl, etc.
974 @c - maybe ask Amelie Zapf to clean it up, or whether I should just
975 @c make whatever changes I feel like.
977 @c FIXME: produces a warning ; key change merge.
978 @c The `line-width' argument is for the \header.
980 @lilypond[quote,verbatim,ragged-right,line-width]
988 tagline = "LilyPond example file by Amelie Zapf,
990 texidoc = "Jazz tune for combo
991 (horns, guitar, piano, bass, drums)."
994 #(set-global-staff-size 16)
995 \include "english.ly"
997 %%%%%%%%%%%% Some macros %%%%%%%%%%%%%%%%%%%
1000 \override NoteHead #'style = #'slash
1001 \override Stem #'transparent = ##t
1004 \revert NoteHead #'style
1005 \revert Stem #'transparent
1007 cr = \override NoteHead #'style = #'cross
1008 ncr = \revert NoteHead #'style
1010 %% insert chord name style stuff here.
1015 %%%%%%%%%%%% Keys'n'thangs %%%%%%%%%%%%%%%%%
1021 Key = { \key c \major }
1023 % ############ Horns ############
1025 % ------ Trumpet ------
1026 trpt = \transpose c d \relative c'' {
1030 trpharmony = \transpose c' d {
1035 \set Staff.instrument = #"Trumpet"
1042 % ------ Alto Saxophone ------
1043 alto = \transpose c a \relative c' {
1047 altoharmony = \transpose c' a {
1052 \set Staff.instrument = #"Alto Sax"
1059 % ------ Baritone Saxophone ------
1060 bari = \transpose c a' \relative c {
1062 c1 c \sl d4^"Solo" d d d \nsl
1064 bariharmony = \transpose c' a \chordmode {
1065 \jzchords s1 s d2:maj e:m7
1069 \set Staff.instrument = #"Bari Sax"
1076 % ------ Trombone ------
1077 tbone = \relative c {
1081 tboneharmony = \chordmode {
1086 \set Staff.instrument = #"Trombone"
1093 % ############ Rhythm Section #############
1095 % ------ Guitar ------
1096 gtr = \relative c'' {
1098 c1 \sl b4 b b b \nsl c1
1100 gtrharmony = \chordmode {
1106 \set Staff.instrument = #"Guitar"
1113 %% ------ Piano ------
1114 rhUpper = \relative c'' {
1119 rhLower = \relative c' {
1125 lhUpper = \relative c' {
1130 lhLower = \relative c {
1139 \set Staff.midiInstrument = "acoustic grand"
1141 \new Voice = "one" \rhUpper
1142 \new Voice = "two" \rhLower
1148 \set Staff.midiInstrument = "acoustic grand"
1150 \new Voice = "one" \lhUpper
1151 \new Voice = "two" \lhLower
1157 \set PianoStaff.instrument = #"Piano"
1158 \new Staff = "upper" \PianoRH
1159 \new Staff = "lower" \PianoLH
1163 % ------ Bass Guitar ------
1164 Bass = \relative c {
1170 \set Staff.instrument = #"Bass"
1177 % ------ Drums ------
1179 hh4 <hh sn>4 hh <hh sn> hh <hh sn>4
1186 bd4 s bd s bd s bd s bd s bd s
1192 \set DrumStaff.instrument = #"Drums"
1193 \new DrumVoice { \voiceOne \up }
1194 \new DrumVoice { \voiceTwo \down }
1198 %%%%%%%%% It All Goes Together Here %%%%%%%%%%%%%%%%%%%%%%
1202 \new StaffGroup = "horns" <<
1203 \new Staff = "trumpet" \trumpet
1204 \new Staff = "altosax" \altosax
1205 \new ChordNames = "barichords" \bariharmony
1206 \new Staff = "barisax" \barisax
1207 \new Staff = "trombone" \trombone
1210 \new StaffGroup = "rhythm" <<
1211 \new ChordNames = "chords" \gtrharmony
1212 \new Staff = "guitar" \guitar
1213 \new PianoStaff = "piano" \piano
1214 \new Staff = "bass" \bass
1215 \new DrumStaff { \drumContents }
1220 \context { \RemoveEmptyStaffContext }
1223 \override BarNumber #'padding = #3
1224 \override RehearsalMark #'padding = #2
1229 \midi { \tempo 4 = 75 }
1233 @node Other templates
1234 @section Other templates
1235 @subsection All headers
1237 This template displays all available headers. Some of them are only
1238 used in the Mutopia project; they don't affect the printed output at
1239 all. They are used if you want the piece to be listed with different
1240 information in the Mutopia database than you wish to have printed on the
1241 music. For example, Mutopia lists the composer of the famous D major
1242 violin concerto as TchaikovskyPI, whereas perhaps you wish to print
1243 "Petr Tchaikowski" on your music.
1245 @ The `line-width' is for \header.
1246 @lilypond[quote,verbatim,ragged-right,line-width]
1249 dedication = "dedication"
1251 subtitle = "Subtitle"
1252 subsubtitle = "Subsubtitle"
1253 composer = "Composer (xxxx-yyyy)"
1257 instrument = "Instrument"
1258 arranger = "Arranger"
1260 texttranslator = "Translator"
1261 copyright = "public domain"
1263 % These are headers used by the Mutopia Project
1264 % http://www.mutopiaproject.org/
1266 mutopiacomposer = ""
1268 mutopiainstrument = ""
1269 date = "composer's dates"
1271 maintainer = "your name here"
1272 maintainerEmail = "your email here"
1273 maintainerWeb = "your home page"
1274 lastupdated = "2004/Aug/26"
1294 @subsection Gregorian template
1296 This example demonstrates how to do modern transcriptions of Gregorian
1297 music. Gregorian music has no measure, no stems; it uses only half and
1298 quarter notes, and two types of barlines, a short one indicating a rest,
1299 and a second one indicating a breath mark.
1301 @lilypond[quote,verbatim,ragged-right]
1302 barOne = { \once \override Staff.BarLine #'bar-size = #2
1304 barTwo = { \once \override Staff.BarLine #'extra-offset = #'(0 . 2)
1305 \once \override Staff.BarLine #'bar-size = #2
1307 chant = \relative c' {
1308 \set Score.timing = ##f
1309 \override Staff.Stem #'transparent = ##t
1318 \midi { \tempo 4=60 }
1323 @node Lilypond-book templates
1324 @section Lilypond-book templates
1326 These templates are for use with @code{lilypond-book}. If you're not familiar
1327 with this program, please refer to @ref{LilyPond-book}.
1331 You can include LilyPond fragments in a LaTeX document.
1334 \documentclass[]@{article@}
1358 You can include LilyPond fragments in Texinfo; in fact, this entire manual
1359 is written in Texinfo.
1367 @@lilypond[verbatim,fragment,ragged-right]
1373 @@lilypond[verbatim,fragment,ragged-right]