1 @node Example templates
2 @chapter Example templates
4 This section of the manual contains templates with the LilyPond score
5 already set up for you. Just add notes, run LilyPond, and enjoy
6 beautiful printed scores!
8 Note that all templates contain a @code{\version "x.y.z"} string. We
9 highly recommend that you always include the @code{\version}, no matter
10 how small your file is. Speaking from personal experience, it's
11 quite frustrating to try to remember which version of LilyPond you were
12 using a few years ago. @code{convert-ly} requires you to declare
13 which version of LilyPond you used.
23 @c more sections to come soon.
24 @c make a note about the \score{} stuff? It might make more sense
25 @c to note that in the tutorial, and reserve this section purely
31 @subsection Notes only
33 The first example gives you a staff with notes, suitable for a solo
34 instrument or a melodic fragment. Cut and paste this into a file,
35 add notes, and you're finished!
37 @lilypond[verbatim,raggedright]
40 melody = \relative c' {
56 @subsection Notes and lyrics
58 The next example demonstrates a simple melody with lyrics. Cut and
59 paste, add notes, then words for the lyrics. This example turns off
60 automatic beaming, which is common for vocal parts. If you want to use
61 automatic beaming, you'll have to change or comment out the relevant
64 @lilypond[verbatim,raggedright]
67 melody = \relative c' {
81 \context Voice = one {
85 \lyricsto "one" \new Lyrics \text
93 @subsection Notes and chords
95 Want to prepare a lead sheet with a melody and chords? Look no farther!
97 @lilypond[verbatim,raggedright]
100 melody = \relative c' {
109 harmonies = \chords {
110 c4:m f:min7 g:maj c:aug d2:dim b:sus
115 \context ChordNames {
116 \set chordChanges = ##t
119 \context Staff = one \melody
128 @subsection Notes, lyrics, and chords.
130 This template allows you to prepare a song with melody, words, and chords.
132 @lilypond[verbatim,raggedright]
135 melody = \relative c' {
147 harmonies = \chords {
153 \context ChordNames {
154 \set chordChanges = ##t
157 \context Voice = one {
161 \lyricsto "one" \new Lyrics \text
169 @node Piano templates
170 @section Piano templates
171 @subsection Solo piano
173 Here's a simple piano staff.
175 @lilypond[verbatim,raggedright]
178 upper = \relative c'' {
186 lower = \relative c {
195 \context PianoStaff <<
196 \set PianoStaff.instrument = "Piano "
197 \context Staff = upper \upper
198 \context Staff = lower \lower
201 \midi { \tempo 4=60 }
206 @subsection Piano and melody with lyrics
208 Here's a typical song format: one staff with the melody and lyrics, with
209 piano accompaniment underneath.
211 @lilypond[verbatim,raggedright]
214 melody = \relative c'' {
226 upper = \relative c'' {
234 lower = \relative c {
244 \context Voice = mel {
248 \lyricsto mel \new Lyrics \text
250 \context PianoStaff <<
251 \context Staff = upper \upper
252 \context Staff = lower \lower
256 \context { \RemoveEmptyStaffContext }
263 @node Small ensembles
264 @section Small ensembles
265 @subsection SATB vocal score
267 Here's a standard four-part SATB vocal score. With larger ensembles,
268 it's often useful to include a section which is included in all
269 parts. For example, the time signature and key signatures are almost
270 always the same for all parts.
272 @lilypond[verbatim,raggedright]
280 sopMusic = \relative c'' {
283 sopWords = \lyrics { hi4 hi hi hi }
285 altoMusic = \relative c' {
288 altoWords =\lyrics { ha4 ha ha ha }
290 tenorMusic = \relative c' {
293 tenorWords = \lyrics { hu4 hu hu hu }
295 bassMusic = \relative c {
298 bassWords = \lyrics { ho4 ho ho ho }
301 \context ChoirStaff <<
302 \context Lyrics = sopranos { s1 }
303 \context Staff = women <<
304 \context Voice = sopranos { \voiceOne << \global \sopMusic >> }
305 \context Voice = altos { \voiceTwo << \global \altoMusic >> }
307 \context Lyrics = altos { s1 }
308 \context Lyrics = tenors { s1 }
309 \context Staff = men <<
311 \context Voice = tenors { \voiceOne <<\global \tenorMusic >> }
312 \context Voice = basses { \voiceTwo <<\global \bassMusic >> }
314 \context Lyrics = basses { s1 }
317 \context Lyrics = sopranos \lyricsto sopranos \sopWords
318 \context Lyrics = altos \lyricsto altos \altoWords
319 \context Lyrics = tenors \lyricsto tenors \tenorWords
320 \context Lyrics = basses \lyricsto basses \bassWords
326 % a little smaller so lyrics can be closer to the staff.
328 minimumVerticalExtent = #'(-3 . 3)
335 @subsection String quartet
337 This template demonstrates a string quartet. It also uses a @code{\global}
338 section for time and key signatures.
340 @lilypond[verbatim,raggedright]
347 violinOne = \relative c''{
348 \set Staff.instrument = "Violin 1 "
352 violinTwo = \relative c''{
353 \set Staff.instrument = "Violin 2 "
357 viola = \relative c'{
358 \set Staff.instrument = "Viola "
363 cello = \relative c'{
364 \set Staff.instrument = "Cello "
371 \new Staff << \global \violinOne >>
372 \new Staff << \global \violinTwo >>
373 \new Staff << \global \viola >>
374 \new Staff << \global \cello >>
385 This is a much more complicated template, for a jazz ensemble. Note that all
386 instruments are notated @code{\key c \major}. This refers to the key in
387 concert pitch; LilyPond will automatically transpose the key if the music
388 is within a @code{\transpose} section.
390 @c TODO must clean up this example.
391 @c - transpositions stated in names (ie "trumpet in Bb" or whatever)
392 @c - one global section, instead of "global" (time) and "key"
393 @c - does it need those wierd macros? sl, nsl, etc.
394 @c - maybe ask Amelie Zapf to clean it up, or whether I should just
395 @c make whatever changes I feel like.
397 @lilypond[verbatim,raggedright]
406 tagline = "LilyPond example file by Amelie Zapf, Berlin 07/07/2003"
407 texidoc = "Jazz tune for combo (horns, guitar, piano, bass, drums)."
410 #(set-global-staff-size 16)
411 \include "english.ly"
413 %%%%%%%%%%%% Some macros %%%%%%%%%%%%%%%%%%%
416 \override NoteHead #'style = #'slash
417 \override Stem #'transparent = ##t
420 \revert NoteHead #'style
421 \revert Stem #'transparent
423 cr = \override NoteHead #'style = #'cross
424 ncr = \revert NoteHead #'style
426 %% insert chord name style stuff here.
431 %%%%%%%%%%%% Keys'n'thangs %%%%%%%%%%%%%%%%%
437 Key = { \key c \major }
439 % ############ Horns ############
440 % ------ Trumpet ------
441 trpt = \transpose c d \relative c'' {
446 trpharmony = \transpose c' d { \jzchords }
449 \set Staff.instrument = #"Trumpet"
456 % ------ Alto Saxophone ------
457 alto = \transpose c a \relative c' {
462 altoharmony = \transpose c' a { \jzchords }
465 \set Staff.instrument = #"Alto Sax"
472 % ------ Baritone Saxophone ------
473 bari = \transpose c a' \relative c {
475 c1 c \sl d4^"Solo" d d d \nsl
478 bariharmony = \transpose c' a \chords { \jzchords s1 s d2:maj e:m7 }
481 \set Staff.instrument = #"Bari Sax"
487 % ------ Trombone ------
488 tbone = \relative c {
493 tboneharmony = \chords { \jzchords }
496 \set Staff.instrument = #"Trombone"
502 % ############ Rhythm Section #############
503 % ------ Guitar ------
504 gtr = \relative c'' {
506 c1 \sl b4 b b b \nsl c1
509 gtrharmony = \chords { \jzchords
515 \set Staff.instrument = #"Guitar"
522 %% ------ Piano ------
523 rhUpper = \relative c'' {
529 rhLower = \relative c' {
535 lhUpper = \relative c' {
541 lhLower = \relative c {
550 \set Staff.midiInstrument = "acoustic grand"
552 \context Voice = one \rhUpper
553 \context Voice = two \rhLower
560 \set Staff.midiInstrument = "acoustic grand"
562 \context Voice = one \lhUpper
563 \context Voice = two \lhLower
568 \context PianoStaff <<
569 \set PianoStaff.instrument = #"Piano"
570 \context Staff = upper \PianoRH
571 \context Staff = lower \PianoLH
575 % ------ Bass Guitar ------
583 \set Staff.instrument = #"Bass"
590 % ------ Drums ------
593 hh4 <hh sn>4 hh <hh sn> hh <hh sn>4
600 bd4 s bd s bd s bd s bd s bd s
606 \set DrumStaff.instrument = #"Drums"
607 \new DrumVoice { \voiceOne \up }
608 \new DrumVoice { \voiceTwo \down }
612 %%%%%%%%% It All Goes Together Here %%%%%%%%%%%%%%%%%%%%%%
616 \context StaffGroup = horns <<
617 \context Staff = trumpet \trumpet
619 \context Staff = altosax \altosax
621 \context ChordNames = barichords \bariharmony
623 \context Staff = barisax \barisax
625 \context Staff = trombone \trombone
628 \context StaffGroup = rhythm <<
629 \context ChordNames = chords \gtrharmony
630 \context Staff = guitar \guitar
631 \context PianoStaff = piano \piano
633 \context Staff = bass \bass
635 \new DrumStaff { \drumContents }
639 \context { \RemoveEmptyStaffContext }
642 \override BarNumber #'padding = #3
643 \override RehearsalMark #'padding = #2
647 \midi { \tempo 4 = 75 }
652 @node Other templates
653 @section Other templates
654 @subsection All headers
656 This template displays all available headers. Some of them are only
657 used in the Mutopia project; they don't affect the printed output at
658 all. They are used if you want the piece to be listed with different
659 information in the Mutopia database than you wish to have printed on the
660 music. For example, Mutopia lists the composer of the famous D major
661 violin concerto as TchaikovskyPI, whereas perhaps you wish to print
662 "Petr Tchaikowski" on your music.
664 @lilypond[verbatim,raggedright]
668 dedication = "dedication"
670 subtitle = "Subtitle"
671 subsubtitle = "Subsubtitle"
672 composer = "Composer (xxxx-yyyy)"
675 instrument = "Instrument"
676 arranger = "Arranger"
678 texttranslator = "Translator"
679 copyright = "public domain"
681 % These are headers used by the Mutopia Project http://www.mutopiaproject.org/
685 mutopiainstrument = ""
686 date = "composer's dates"
688 maintainer = "your name here"
689 maintainerEmail = "your email here"
690 maintainerWeb = "your home page"
691 lastupdated = "2004/Aug/26"
712 @subsection Gregorian template
714 This example demonstrates how to do modern transcriptions of Gregorian
715 music. Gregorian music has no measure, no stems; it uses only half and
716 quarter notes, and two types of barlines, a short one indicating a rest,
717 and a second one indicating a breath mark.
720 @lilypond[verbatim,raggedright]
722 barOne = { \once \override Staff.BarLine #'bar-size = #2
724 barTwo = { \once \override Staff.BarLine #'extra-offset = #'(0 . 2)
725 \once \override Staff.BarLine #'bar-size = #2
727 chant = \relative c' {
728 \set Score.timing = ##f
729 \override Staff.Stem #'transparent = ##t
738 \midi { \tempo 4=60 }
743 @subsection Bagpipe music
745 Here's an example of bagpipe music. It demonstrates a big strength of
746 LilyPond, compared to graphical score editors: in LilyPond, you can
747 very easily reuse small segments of music without writing them out
748 completely. This template defines a large number of small segments
749 (@code{taor, grip, thrd,} etc), which can be reused easily.
751 @lilypond[verbatim,raggedright]
753 taor = { \grace { g32[ d' g e'] } }
754 grip = { \grace { g32[ b g ] } }
755 thrd = { \grace { g32[ d' c'] } }
756 birl = { \grace { g32[ a g] } }
757 gstd = { \grace { g'32[ d' g] } }
758 fgg = { \grace { f32[ g'32] } }
759 dblb = { \grace { g'32[ b d'] } }
760 dblc = { \grace { g'32[ c' d'] } }
761 dble = { \grace { g'32[ e' f'] } }
762 dblf = { \grace { g'32[ f' g'] } }
763 dblg = { \grace { g'32[ f'] } }
764 dbla = { \grace { a'32[ g'] } }
765 lgg = { \grace { g32 } }
766 lag = { \grace { a32 } }
767 cg = { \grace { c'32 } }
768 eg = { \grace { e'32 } }
769 gg = { \grace { g'32 } }
770 dg = { \grace { d'32 } }
771 hag = { \grace { a'32 } }
772 gefg = { \grace { g'32[ e' f'] } }
773 efg = { \grace { e'32[ f'] } }
774 gdcg = { \grace { g'32[ d' c'] } }
775 gcdg = { \grace { g'32[ c' d'] } }
778 #(add-grace-property 'Voice 'Stem 'length 6)
784 \gg f'4 e'8 \thrd d'4. |
786 \gg d'4 f'8 \dble e'4. ( | \noBreak
787 e'8) d'4 \gg d'4 e'8 |
791 \dblf f'2.( f'4) d'8 |
793 \dblg g'4 a'8 \gg a'4. |
794 \thrd d'4.( d'4) \eg a8 |
796 \dble e'4 \lag e'8 \gg e'16[ d'8. e'8] \gg f'4 g'8 |
800 \gg f'4 e'8 \thrd d'4. |
802 \dblg g'4 a'8 \gg a'4. |
803 \thrd d'4.( d'4) f'8 |
806 \dblg g'4 e'8( e'8) \dblf f'8.[ e'16] |
807 \thrd d'4.( d'4) \cg d'8 |
808 \gg c'4 e'8 \thrd d'4.( |