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
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.instrumentName = "Piano "
180 \new Staff = "upper" \upper
181 \new Staff = "lower" \lower
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 }
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" }
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.instrumentName = "Violin 1 "
407 violinTwo = \new Voice { \relative c''{
408 \set Staff.instrumentName = "Violin 2 "
413 viola = \new Voice { \relative c' {
414 \set Staff.instrumentName = "Viola "
420 cello = \new Voice { \relative c' {
421 \set Staff.instrumentName = "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.instrumentName = "Violin 1 "
466 \bar "|." }} %*********************************
467 Violintwo = \new Voice { \relative c''{
468 \set Staff.instrumentName = "Violin 2 "
472 \bar "|." }} %*********************************
473 Viola = \new Voice { \relative c' {
474 \set Staff.instrumentName = "Viola "
479 \bar "|." }} %*********************************
480 Cello = \new Voice { \relative c' {
481 \set Staff.instrumentName = "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
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.instrumentName = "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.instrumentName = "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.instrumentName = "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.instrumentName = "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 }
950 \override BarLine #'transparent = ##t
952 % incipit should not start with a start delimiter
953 \remove "System_start_delimiter_engraver"
959 \override Slur #'transparent = ##t
961 % Comment in the below "\remove" command to allow line
962 % breaking also at those barlines where a note overlaps
963 % into the next bar. The command is commented out in this
964 % short example score, but especially for large scores, you
965 % will typically yield better line breaking and thus improve
966 % overall spacing if you comment in the following command.
967 %\remove "Forbid_line_break_engraver"
974 @appendixsubsec Gregorian transcription template
976 This example demonstrates how to do modern transcription of Gregorian
977 music. Gregorian music has no measure, no stems; it uses only half and
978 quarter noteheads, and special marks, indicating rests of different length.
980 @lilypond[quote,verbatim,ragged-right]
981 \include "gregorian-init.ly"
984 chant = \relative c' {
985 \set Score.timing = ##f
987 g4 b a2 f2 \divisioMaior
988 g4( f) f( g) a2 \finalis
992 Lo -- rem ip -- sum do -- lor sit a -- met
997 \new Voice = "melody" {
1000 \new Lyrics = "one" \lyricsto melody \verba
1006 \remove "Time_signature_engraver"
1007 \remove "Bar_engraver"
1008 \override Stem #'transparent = ##t
1012 \override Stem #'length = #0
1024 @appendixsec Jazz combo
1026 This is a much more complicated template, for a jazz ensemble. Note that all
1027 instruments are notated in @code{\key c \major}. This refers to the key in
1028 concert pitch; LilyPond will automatically transpose the key if the music
1029 is within a @code{\transpose} section.
1031 @c TODO must clean up this jazz combo example
1032 @c - transpositions stated in names (ie "trumpet in Bb" or whatever)
1033 @c - one global section, instead of "global" (time) and "key"
1034 @c - does it need those wierd macros? sl, nsl, etc.
1035 @c - maybe ask Amelie Zapf to clean it up, or whether I should just
1036 @c make whatever changes I feel like.
1038 @c FIXME: produces a warning ; key change merge.
1039 @c The `line-width' argument is for the \header.
1041 @lilypond[quote,verbatim,ragged-right,line-width]
1051 "LilyPond example file by Amelie Zapf,"
1055 texidoc = "Jazz tune for combo
1056 (horns, guitar, piano, bass, drums)."
1059 #(set-global-staff-size 16)
1060 \include "english.ly"
1062 %%%%%%%%%%%% Some macros %%%%%%%%%%%%%%%%%%%
1065 \override NoteHead #'style = #'slash
1066 \override Stem #'transparent = ##t
1069 \revert NoteHead #'style
1070 \revert Stem #'transparent
1072 cr = \override NoteHead #'style = #'cross
1073 ncr = \revert NoteHead #'style
1075 %% insert chord name style stuff here.
1080 %%%%%%%%%%%% Keys'n'thangs %%%%%%%%%%%%%%%%%
1086 Key = { \key c \major }
1088 % ############ Horns ############
1090 % ------ Trumpet ------
1091 trpt = \transpose c d \relative c'' {
1095 trpharmony = \transpose c' d {
1100 \set Staff.instrumentName = #"Trumpet"
1107 % ------ Alto Saxophone ------
1108 alto = \transpose c a \relative c' {
1112 altoharmony = \transpose c' a {
1117 \set Staff.instrumentName = #"Alto Sax"
1124 % ------ Baritone Saxophone ------
1125 bari = \transpose c a' \relative c {
1127 c1 c \sl d4^"Solo" d d d \nsl
1129 bariharmony = \transpose c' a \chordmode {
1130 \jzchords s1 s d2:maj e:m7
1134 \set Staff.instrumentName = #"Bari Sax"
1141 % ------ Trombone ------
1142 tbone = \relative c {
1146 tboneharmony = \chordmode {
1151 \set Staff.instrumentName = #"Trombone"
1158 % ############ Rhythm Section #############
1160 % ------ Guitar ------
1161 gtr = \relative c'' {
1163 c1 \sl b4 b b b \nsl c1
1165 gtrharmony = \chordmode {
1171 \set Staff.instrumentName = #"Guitar"
1178 %% ------ Piano ------
1179 rhUpper = \relative c'' {
1184 rhLower = \relative c' {
1190 lhUpper = \relative c' {
1195 lhLower = \relative c {
1204 \set Staff.midiInstrument = "acoustic grand"
1206 \new Voice = "one" \rhUpper
1207 \new Voice = "two" \rhLower
1213 \set Staff.midiInstrument = "acoustic grand"
1215 \new Voice = "one" \lhUpper
1216 \new Voice = "two" \lhLower
1222 \set PianoStaff.instrumentName = #"Piano"
1223 \new Staff = "upper" \PianoRH
1224 \new Staff = "lower" \PianoLH
1228 % ------ Bass Guitar ------
1229 Bass = \relative c {
1235 \set Staff.instrumentName = #"Bass"
1242 % ------ Drums ------
1244 hh4 <hh sn>4 hh <hh sn> hh <hh sn>4
1251 bd4 s bd s bd s bd s bd s bd s
1257 \set DrumStaff.instrumentName = #"Drums"
1258 \new DrumVoice { \voiceOne \up }
1259 \new DrumVoice { \voiceTwo \down }
1263 %%%%%%%%% It All Goes Together Here %%%%%%%%%%%%%%%%%%%%%%
1267 \new StaffGroup = "horns" <<
1268 \new Staff = "trumpet" \trumpet
1269 \new Staff = "altosax" \altosax
1270 \new ChordNames = "barichords" \bariharmony
1271 \new Staff = "barisax" \barisax
1272 \new Staff = "trombone" \trombone
1275 \new StaffGroup = "rhythm" <<
1276 \new ChordNames = "chords" \gtrharmony
1277 \new Staff = "guitar" \guitar
1278 \new PianoStaff = "piano" \piano
1279 \new Staff = "bass" \bass
1280 \new DrumStaff { \drumContents }
1285 \context { \RemoveEmptyStaffContext }
1288 \override BarNumber #'padding = #3
1289 \override RehearsalMark #'padding = #2
1300 This isn't very useful, and only duplicates material in
1301 "global issues". And if this info changes, this section often
1304 @no de Other templates
1305 @se ction Other templates
1306 @su bsection All headers
1308 This template displays all available headers. Some of them are only
1309 used in the Mutopia project; they don't affect the printed output at
1310 all. They are used if you want the piece to be listed with different
1311 information in the Mutopia database than you wish to have printed on the
1312 music. For example, Mutopia lists the composer of the famous D major
1313 violin concerto as TchaikovskyPI, whereas perhaps you wish to print
1314 "Petr Tchaikowski" on your music.
1316 @ The `line-width' is for \header.
1317 @li lypond[quote,verbatim,ragged-right,line-width]
1320 dedication = "dedication"
1322 subtitle = "Subtitle"
1323 subsubtitle = "Subsubtitle"
1324 composer = "Composer (xxxx-yyyy)"
1328 instrument = "Instrument"
1329 arranger = "Arranger"
1331 texttranslator = "Translator"
1332 copyright = "public domain"
1334 % These are headers used by the Mutopia Project
1335 % http://www.mutopiaproject.org/
1337 mutopiacomposer = ""
1339 mutopiainstrument = ""
1340 date = "composer's dates"
1342 maintainer = "your name here"
1343 maintainerEmail = "your email here"
1344 maintainerWeb = "your home page"
1345 lastupdated = "2004/Aug/26"
1367 @node Lilypond-book templates
1368 @appendixsec Lilypond-book templates
1370 These templates are for use with @code{lilypond-book}. If you're not familiar
1371 with this program, please refer to @ref{LilyPond-book}.
1373 @appendixsubsec LaTeX
1375 You can include LilyPond fragments in a LaTeX document.
1378 \documentclass[]@{article@}
1400 @appendixsubsec Texinfo
1402 You can include LilyPond fragments in Texinfo; in fact, this entire manual
1403 is written in Texinfo.
1411 @@lilypond[verbatim,fragment,ragged-right]
1417 @@lilypond[verbatim,fragment,ragged-right]