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
149 \midi { \tempo 4=60 }
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.instrument = "Piano "
180 \new Staff = "upper" \upper
181 \new Staff = "lower" \lower
184 \midi { \tempo 4=60 }
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 }
239 \midi { \tempo 4=60 }
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" }
284 \midi { \tempo 4=60 }
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.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 @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.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 @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)
727 @c bad node name to avoid node name confict
728 @node Ancient notation templates
729 @appendixsec Ancient notation templates
731 @appendixsubsec 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 @appendixsubsec Gregorian transcription template
962 This example demonstrates how to do modern transcription of Gregorian
963 music. Gregorian music has no measure, no stems; it uses only half and
964 quarter noteheads, and special marks, indicating rests of different length.
966 @lilypond[quote,verbatim,ragged-right]
967 \include "gregorian-init.ly"
970 chant = \relative c' {
971 \set Score.timing = ##f
973 g4 b a2 f2 \divisioMaior
974 g4( f) f( g) a2 \finalis
978 Lo -- rem ip -- sum do -- lor sit a -- met
983 \new Voice = "melody" {
986 \new Lyrics = "one" \lyricsto melody \verba
992 \remove "Time_signature_engraver"
993 \remove "Bar_engraver"
994 \override Stem #'transparent = ##t
998 \override Stem #'length = #0
1010 @appendixsec Jazz combo
1012 This is a much more complicated template, for a jazz ensemble. Note that all
1013 instruments are notated in @code{\key c \major}. This refers to the key in
1014 concert pitch; LilyPond will automatically transpose the key if the music
1015 is within a @code{\transpose} section.
1017 @c TODO must clean up this jazz combo example
1018 @c - transpositions stated in names (ie "trumpet in Bb" or whatever)
1019 @c - one global section, instead of "global" (time) and "key"
1020 @c - does it need those wierd macros? sl, nsl, etc.
1021 @c - maybe ask Amelie Zapf to clean it up, or whether I should just
1022 @c make whatever changes I feel like.
1024 @c FIXME: produces a warning ; key change merge.
1025 @c The `line-width' argument is for the \header.
1027 @lilypond[quote,verbatim,ragged-right,line-width]
1037 "LilyPond example file by Amelie Zapf,"
1041 texidoc = "Jazz tune for combo
1042 (horns, guitar, piano, bass, drums)."
1045 #(set-global-staff-size 16)
1046 \include "english.ly"
1048 %%%%%%%%%%%% Some macros %%%%%%%%%%%%%%%%%%%
1051 \override NoteHead #'style = #'slash
1052 \override Stem #'transparent = ##t
1055 \revert NoteHead #'style
1056 \revert Stem #'transparent
1058 cr = \override NoteHead #'style = #'cross
1059 ncr = \revert NoteHead #'style
1061 %% insert chord name style stuff here.
1066 %%%%%%%%%%%% Keys'n'thangs %%%%%%%%%%%%%%%%%
1072 Key = { \key c \major }
1074 % ############ Horns ############
1076 % ------ Trumpet ------
1077 trpt = \transpose c d \relative c'' {
1081 trpharmony = \transpose c' d {
1086 \set Staff.instrument = #"Trumpet"
1093 % ------ Alto Saxophone ------
1094 alto = \transpose c a \relative c' {
1098 altoharmony = \transpose c' a {
1103 \set Staff.instrument = #"Alto Sax"
1110 % ------ Baritone Saxophone ------
1111 bari = \transpose c a' \relative c {
1113 c1 c \sl d4^"Solo" d d d \nsl
1115 bariharmony = \transpose c' a \chordmode {
1116 \jzchords s1 s d2:maj e:m7
1120 \set Staff.instrument = #"Bari Sax"
1127 % ------ Trombone ------
1128 tbone = \relative c {
1132 tboneharmony = \chordmode {
1137 \set Staff.instrument = #"Trombone"
1144 % ############ Rhythm Section #############
1146 % ------ Guitar ------
1147 gtr = \relative c'' {
1149 c1 \sl b4 b b b \nsl c1
1151 gtrharmony = \chordmode {
1157 \set Staff.instrument = #"Guitar"
1164 %% ------ Piano ------
1165 rhUpper = \relative c'' {
1170 rhLower = \relative c' {
1176 lhUpper = \relative c' {
1181 lhLower = \relative c {
1190 \set Staff.midiInstrument = "acoustic grand"
1192 \new Voice = "one" \rhUpper
1193 \new Voice = "two" \rhLower
1199 \set Staff.midiInstrument = "acoustic grand"
1201 \new Voice = "one" \lhUpper
1202 \new Voice = "two" \lhLower
1208 \set PianoStaff.instrument = #"Piano"
1209 \new Staff = "upper" \PianoRH
1210 \new Staff = "lower" \PianoLH
1214 % ------ Bass Guitar ------
1215 Bass = \relative c {
1221 \set Staff.instrument = #"Bass"
1228 % ------ Drums ------
1230 hh4 <hh sn>4 hh <hh sn> hh <hh sn>4
1237 bd4 s bd s bd s bd s bd s bd s
1243 \set DrumStaff.instrument = #"Drums"
1244 \new DrumVoice { \voiceOne \up }
1245 \new DrumVoice { \voiceTwo \down }
1249 %%%%%%%%% It All Goes Together Here %%%%%%%%%%%%%%%%%%%%%%
1253 \new StaffGroup = "horns" <<
1254 \new Staff = "trumpet" \trumpet
1255 \new Staff = "altosax" \altosax
1256 \new ChordNames = "barichords" \bariharmony
1257 \new Staff = "barisax" \barisax
1258 \new Staff = "trombone" \trombone
1261 \new StaffGroup = "rhythm" <<
1262 \new ChordNames = "chords" \gtrharmony
1263 \new Staff = "guitar" \guitar
1264 \new PianoStaff = "piano" \piano
1265 \new Staff = "bass" \bass
1266 \new DrumStaff { \drumContents }
1271 \context { \RemoveEmptyStaffContext }
1274 \override BarNumber #'padding = #3
1275 \override RehearsalMark #'padding = #2
1280 \midi { \tempo 4 = 75 }
1286 This isn't very useful, and only duplicates material in
1287 "global issues". And if this info changes, this section often
1290 @no de Other templates
1291 @se ction Other templates
1292 @su bsection All headers
1294 This template displays all available headers. Some of them are only
1295 used in the Mutopia project; they don't affect the printed output at
1296 all. They are used if you want the piece to be listed with different
1297 information in the Mutopia database than you wish to have printed on the
1298 music. For example, Mutopia lists the composer of the famous D major
1299 violin concerto as TchaikovskyPI, whereas perhaps you wish to print
1300 "Petr Tchaikowski" on your music.
1302 @ The `line-width' is for \header.
1303 @li lypond[quote,verbatim,ragged-right,line-width]
1306 dedication = "dedication"
1308 subtitle = "Subtitle"
1309 subsubtitle = "Subsubtitle"
1310 composer = "Composer (xxxx-yyyy)"
1314 instrument = "Instrument"
1315 arranger = "Arranger"
1317 texttranslator = "Translator"
1318 copyright = "public domain"
1320 % These are headers used by the Mutopia Project
1321 % http://www.mutopiaproject.org/
1323 mutopiacomposer = ""
1325 mutopiainstrument = ""
1326 date = "composer's dates"
1328 maintainer = "your name here"
1329 maintainerEmail = "your email here"
1330 maintainerWeb = "your home page"
1331 lastupdated = "2004/Aug/26"
1353 @node Lilypond-book templates
1354 @appendixsec Lilypond-book templates
1356 These templates are for use with @code{lilypond-book}. If you're not familiar
1357 with this program, please refer to @ref{LilyPond-book}.
1359 @appendixsubsec LaTeX
1361 You can include LilyPond fragments in a LaTeX document.
1364 \documentclass[]@{article@}
1386 @appendixsubsec Texinfo
1388 You can include LilyPond fragments in Texinfo; in fact, this entire manual
1389 is written in Texinfo.
1397 @@lilypond[verbatim,fragment,ragged-right]
1403 @@lilypond[verbatim,fragment,ragged-right]