]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/examples.itely
Minor editing.
[lilypond.git] / Documentation / user / examples.itely
1 @c -*- coding: latin-1; mode: texinfo; -*-
2 @node Example templates
3 @chapter Example templates
4
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!
8
9 @c bad node name for ancient notation to avoid confict
10 @menu
11 * Suggestions for writing LilyPond files::
12 * Single staff::
13 * Piano templates::
14 * String quartet::
15 * Vocal ensembles::
16 * Ancient notation templates::
17 * Jazz combo::
18 * Other templates::
19 * Lilypond-book templates::
20 @end menu
21
22 @c TODO explain \score{} ?  Maybe add a note to the tutorial?
23
24 @node Suggestions for writing LilyPond files
25 @section Suggestions for writing LilyPond files
26
27 Now you're ready to begin writing larger LilyPond files -- not just the
28 little examples in the tutorial, but whole pieces.  But how should you
29 go about doing it?
30
31 The best answer is ``however you want to do it.''  As long as LilyPond
32 can understand your files and produces the output that you want, it
33 doesn't matter what your files look like.  That said, sometimes we
34 make mistakes when writing files.  If LilyPond can't understand your
35 files, or produces output that you don't like, how do you fix the
36 problem?
37
38 Here are a few suggestions that can help you to avoid or fix
39 problems:
40
41 @itemize @bullet
42 @item Include @code{\version} numbers in every file.  Note that all
43 templates contain a @code{\version "2.4.0"} string.  We
44 highly recommend that you always include the @code{\version}, no matter
45 how small your file is.  Speaking from personal experience, it's
46 quite frustrating to try to remember which version of LilyPond you were
47 using a few years ago.  @code{convert-ly} requires you to declare
48 which version of LilyPond you used.
49
50 @item Include checks: See @ref{Bar check} and @ref{Octave check}.  If you
51 include checks every so often, then if you make a mistake, you can pinpoint
52 it quicker.  How often is ``every so often''?  It depends on the complexity
53 of the music.  For very simple music, perhaps just once or twice.  For
54 very complex music, every bar.
55
56 @item One bar per line.  If there is anything complicated, either in the music
57 itself or in the output you desire, it's often good to write only one bar
58 per line.  Saving screen space by cramming eight bars per line just isn't
59 worth it if you have to `debug' your files.
60
61 @item Comment your files, with either bar numbers (every so often) or
62 references to musical themes (``second theme in violins'', ``fourth
63 variation'').  You may not need it when you're writing the piece for
64 the first time, but if you want to go back and change something two
65 or three years later, you won't know how your file is structured if you
66 don't comment the file.
67
68 @end itemize
69
70 @node Single staff
71 @section Single staff
72 @subsection Notes only
73
74 The first example gives you a staff with notes, suitable for a solo
75 instrument or a melodic fragment.  Cut and paste this into a file,
76 add notes, and you're finished!
77
78 @lilypond[quote,verbatim,raggedright]
79 \version "2.4.0"
80 melody = \relative c' {
81    \clef treble
82    \key c \major
83    \time 4/4
84
85    a4 b c d
86 }
87
88 \score {
89    \new Staff \melody
90    \layout { }
91    \midi { \tempo 4=60 }
92 }
93 @end lilypond
94
95 @subsection Notes and lyrics
96
97 The next example demonstrates a simple melody with lyrics.  Cut and
98 paste, add notes, then words for the lyrics.  This example turns off
99 automatic beaming, which is common for vocal parts.  If you want to use
100 automatic beaming, you'll have to change or comment out the relevant
101 line.
102
103 @lilypond[quote,verbatim,raggedright]
104 \version "2.4.0"
105 melody = \relative c' {
106    \clef treble
107    \key c \major
108    \time 4/4
109
110    a4 b c d
111 }
112
113 text = \lyricmode {
114    Aaa Bee Cee Dee
115 }
116
117 \score{
118    <<
119       \context Voice = one {
120          \autoBeamOff
121          \melody
122       }
123       \lyricsto "one" \new Lyrics \text
124    >>
125    \layout { }
126    \midi { \tempo 4=60 }
127 }
128 @end lilypond
129
130 @subsection Notes and chords
131
132 Want to prepare a lead sheet with a melody and chords?  Look no further!
133
134 @lilypond[quote,verbatim,raggedright]
135 \version "2.4.0"
136 melody = \relative c' {
137    \clef treble
138    \key c \major
139    \time 4/4
140
141    f4 e8[ c] d4 g |
142    a2 ~ a2 |
143 }
144
145 harmonies = \chordmode {
146    c4:m f:min7 g:maj c:aug d2:dim b:sus
147 }
148
149 \score {
150    <<
151       \context ChordNames {
152          \set chordChanges = ##t
153          \harmonies
154       }
155    \context Staff = one \melody
156    >>
157
158    \layout{ }
159    \midi { \tempo 4=60}
160 }
161 @end lilypond
162
163 @subsection Notes, lyrics, and chords.
164
165 This template allows you to prepare a song with melody, words, and chords.
166
167 @lilypond[quote,verbatim,raggedright]
168 \version "2.4.0"
169 melody = \relative c' {
170    \clef treble
171    \key c \major
172    \time 4/4
173
174    a b c d
175 }
176
177 text = \lyricmode {
178    Aaa Bee Cee Dee
179 }
180
181 harmonies = \chordmode {
182    a2 c2
183 }
184
185 \score {
186    <<
187       \context ChordNames {
188          \set chordChanges = ##t
189          \harmonies
190       }
191    \context Voice = one {
192       \autoBeamOff
193       \melody
194    }
195    \lyricsto "one" \new Lyrics \text
196    >>
197    \layout { }
198    \midi { \tempo 4=60 }
199 }
200 @end lilypond
201
202 @node Piano templates
203 @section Piano templates
204 @subsection Solo piano
205
206 Here is a simple piano staff.
207
208 @lilypond[quote,verbatim,raggedright]
209 \version "2.4.0"
210 upper = \relative c'' {
211    \clef treble
212    \key c \major
213    \time 4/4
214
215    a b c d
216 }
217
218 lower = \relative c {
219    \clef bass
220    \key c \major
221    \time 4/4
222
223    a2 c
224 }
225
226 \score {
227    \context PianoStaff <<
228       \set PianoStaff.instrument = "Piano  "
229       \context Staff = upper \upper
230       \context Staff = lower \lower
231    >>
232    \layout { }
233    \midi { \tempo 4=60 }
234 }
235 @end lilypond
236
237 @subsection Piano and melody with lyrics
238
239 Here is a typical song format: one staff with the melody and lyrics, with
240 piano accompaniment underneath.
241
242 @lilypond[quote,verbatim,raggedright]
243 \version "2.4.0"
244 melody = \relative c'' {
245    \clef treble
246    \key c \major
247    \time 4/4
248
249    a b c d
250 }
251
252 text = \lyricmode {
253    Aaa Bee Cee Dee
254 }
255
256 upper = \relative c'' {
257    \clef treble
258    \key c \major
259    \time 4/4
260
261    a b c d
262 }
263
264 lower = \relative c {
265    \clef bass
266    \key c \major
267    \time 4/4
268
269    a2 c
270 }
271
272 \score {
273    <<
274       \context Voice = mel {
275           \autoBeamOff
276           \melody
277       }
278       \lyricsto mel \new Lyrics \text
279
280       \context PianoStaff <<
281          \context Staff = upper \upper
282          \context Staff = lower \lower
283       >>
284    >>
285    \layout {
286       \context { \RemoveEmptyStaffContext }
287    }
288    \midi { \tempo 4=60 }
289 }
290 @end lilypond
291
292
293 @subsection Piano centered lyrics
294
295 Instead of having a full staff for the melody and lyrics, you can place
296 the lyrics between the piano staff (and omit the separate melody staff).
297
298 @lilypond[quote,verbatim,raggedright]
299 \version "2.4.0"
300 upper = \relative c'' {
301    \clef treble
302    \key c \major
303    \time 4/4
304
305    a b c d
306 }
307
308 lower = \relative c {
309    \clef bass
310    \key c \major
311    \time 4/4
312
313    a2 c
314 }
315
316 text = \lyricmode {
317    Aaa Bee Cee Dee
318 }
319
320 \score {
321   \context GrandStaff <<
322     \context Staff = upper {
323         \context Voice = singer \upper }
324     \lyricsto "singer" \new Lyrics \text
325     \context Staff = lower <<
326       \clef bass
327       \lower
328     >>
329   >>
330   \layout {
331     \context { \GrandStaff \accepts "Lyrics" }
332     \context { \Lyrics \consists "Bar_engraver" }
333   }
334   \midi { \tempo 4=60 }
335 }
336 @end lilypond
337
338
339 @subsection Piano centered dynamics
340
341 Many piano scores have the dynamics centered between the two
342 staffs.  This requires a bit of tweaking to implement, but
343 since the template is right here, you don't have to do the
344 tweaking yourself.
345
346 @lilypond[quote,verbatim,raggedright]
347 \version "2.4.0"
348 upper = \relative c'' {
349   \clef treble
350   \key c \major
351   \time 4/4
352
353   a b c d
354 }
355
356 lower = \relative c {
357   \clef bass
358   \key c \major
359   \time 4/4
360
361   a2 c
362 }
363
364 dynamics = {
365   s2\fff\> s4
366   s\!\pp
367 }
368
369 pedal = {
370   s2\sustainDown s2\sustainUp
371 }
372
373 \score {
374   \context PianoStaff <<
375     \context Staff=upper \upper
376     \context Dynamics=dynamics \dynamics
377     \context Staff=lower <<
378       \clef bass
379       \lower
380     >>
381     \context Dynamics=pedal \pedal
382   >>
383   \layout {
384     \context {
385       \type "Engraver_group_engraver"
386       \name Dynamics
387       \alias Voice % So that \cresc works, for example.
388       \consists "Output_property_engraver"
389
390       minimumVerticalExtent = #'(-1 . 1)
391       pedalSustainStrings = #'("Ped." "*Ped." "*")
392       pedalUnaCordaStrings = #'("una corda" "" "tre corde")
393
394       \consists "Piano_pedal_engraver"
395       \consists "Script_engraver"
396       \consists "Dynamic_engraver"
397       \consists "Text_engraver"
398
399       \override TextScript #'font-size = #2
400       \override TextScript #'font-shape = #'italic
401       \override DynamicText #'extra-offset = #'(0 . 2.5)
402       \override Hairpin #'extra-offset = #'(0 . 2.5)
403
404       \consists "Skip_event_swallow_translator"
405
406       \consists "Axis_group_engraver"
407     }
408     \context {
409       \PianoStaff
410       \accepts Dynamics
411       \override VerticalAlignment #'forced-distance = #7
412     }
413   }
414   \midi {
415     \context {
416       \type "Performer_group_performer"
417       \name Dynamics
418       \consists "Piano_pedal_performer"
419       \consists "Span_dynamic_performer"
420       \consists "Dynamic_performer"
421     }
422     \context {
423       \PianoStaff
424       \accepts Dynamics
425     }
426   }
427 }
428 @end lilypond
429
430
431 @node String quartet
432 @section String quartet
433 @subsection String quartet
434
435 This template demonstrates a string quartet.  It also uses a @code{\global}
436 section for time and key signatures.
437
438 @lilypond[quote,verbatim,raggedright]
439 \version "2.4.0"
440
441 global= {
442   \time 4/4
443   \key c \major
444 }
445
446 violinOne = \new Voice { \relative c''{
447   \set Staff.instrument = "Violin 1 "
448
449   c2 d e1
450
451 \bar "|." }}
452 violinTwo = \new Voice { \relative c''{
453   \set Staff.instrument = "Violin 2 "
454
455   g2 f e1
456
457 \bar "|." }}
458 viola = \new Voice { \relative c' {
459   \set Staff.instrument = "Viola "
460   \clef alto
461
462   e2 d c1
463
464 \bar "|." }}
465 cello = \new Voice { \relative c' {
466   \set Staff.instrument = "Cello     "
467   \clef bass
468
469   c2 b a1
470
471 \bar "|."}}
472
473 \score {
474    \new StaffGroup <<
475       \new Staff << \global \violinOne >>
476       \new Staff << \global \violinTwo >>
477       \new Staff << \global \viola >>
478       \new Staff << \global \cello >>
479    >>
480    \layout { }
481    \midi { \tempo 4=60}
482 }
483 @end lilypond
484
485 @subsection String quartet parts
486
487 The previous example produces a nice string quartet, but what if you
488 needed to print parts?  This template demonstrates how to use the
489 @code{\tag} feature to easily split a piece into individual parts.
490
491 You need to split this template into separate files; the filenames
492 are contained in comments at the beginning of each file.  @code{piece.ly}
493 contains all the music definitions.  The other files -- @code{score.ly},
494 @code{vn1.ly}, @code{vn2.ly}, @code{vla.ly}, and
495 @code{vlc.ly} -- produce the appropiate part.
496
497 @verbatim
498 %%%%% piece.ly
499 \version "2.4.0"
500
501 global= {
502   \time 4/4
503   \key c \major
504 }
505
506 Violinone = \new Voice { \relative c''{
507   \set Staff.instrument = "Violin 1 "
508
509   c2 d e1
510
511 \bar "|." }}   %*********************************
512 Violintwo = \new Voice { \relative c''{
513   \set Staff.instrument = "Violin 2 "
514
515   g2 f e1
516
517 \bar "|." }}   %*********************************
518 Viola = \new Voice { \relative c' {
519   \set Staff.instrument = "Viola "
520   \clef alto
521
522   e2 d c1
523
524 \bar "|." }}   %*********************************
525 Cello = \new Voice { \relative c' {
526   \set Staff.instrument = "Cello     "
527   \clef bass
528
529   c2 b a1
530
531 \bar "|."}}   %**********************************
532
533 music = {
534   <<
535     \tag #'(score vn1) \new Staff { << \global \Violinone >> }
536     \tag #'(score vn2) \new Staff { << \global \Violintwo>> }
537     \tag #'(score vla) \new Staff { << \global \Viola>> }
538     \tag #'(score vlc) \new Staff { << \global \Cello>> }
539   >>
540 }
541
542
543
544 %%%%% score.ly
545 \version "2.4.0"
546 \include "piece.ly"
547 #(set-global-staff-size 14)
548 \score {
549   \new StaffGroup \keepWithTag #'score \music
550   \layout { }
551   \midi { \tempo 4 = 60 }
552 }
553
554
555 %%%%% vn1.ly
556 \version "2.4.0"
557 \include "piece.ly"
558 \score { 
559   \keepWithTag #'vn1 \music
560   \layout { }
561 }
562
563
564 %%%%% vn2.ly
565 \version "2.4.0"
566 \include "piece.ly"
567 \score { 
568   \keepWithTag #'vn2 \music
569   \layout { }
570 }
571
572
573 %%%%% vla.ly
574 \version "2.4.0"
575 \include "piece.ly"
576 \score { 
577   \keepWithTag #'vla \music
578   \layout { }
579 }
580
581
582 %%%%% vlc.ly
583 \version "2.4.0"
584 \include "piece.ly"
585 \score { 
586   \keepWithTag #'vlc \music
587   \layout { }
588 }
589 @end verbatim
590
591
592 @node Vocal ensembles
593 @section Vocal ensembles
594
595 @subsection SATB vocal score
596
597 Here is a standard four-part SATB vocal score.  With larger ensembles,
598 it's often useful to include a section which is included in all
599 parts.  For example, the time signature and key signatures are almost
600 always the same for all parts.
601
602 @lilypond[quote,verbatim,raggedright]
603 \version "2.4.0"
604 global = {
605    \key c \major
606    \time 4/4
607 }
608
609 sopMusic = \relative c'' {
610    c4 c c8[( b)] c4
611 }
612 sopWords = \lyricmode {
613    hi hi hi hi
614 }
615
616 altoMusic = \relative c' {
617    e4 f d e
618 }
619 altoWords =\lyricmode {
620    ha ha ha ha
621 }
622
623 tenorMusic = \relative c' {
624    g4 a f g
625 }
626 tenorWords = \lyricmode {
627    hu hu hu hu
628 }
629
630 bassMusic = \relative c {
631    c4 c g c
632 }
633 bassWords = \lyricmode {
634    ho ho ho ho
635 }
636
637 \score {
638    \context ChoirStaff <<
639       \context Lyrics = sopranos { s1 }
640       \context Staff = women <<
641          \context Voice =
642            sopranos { \voiceOne << \global \sopMusic >> }
643          \context Voice =
644            altos { \voiceTwo << \global \altoMusic >> }
645       >>
646       \context Lyrics = altos { s1 }
647       \context Lyrics = tenors { s1 }
648       \context Staff = men <<
649          \clef bass
650          \context Voice =
651            tenors { \voiceOne <<\global \tenorMusic >> }
652          \context Voice =
653            basses { \voiceTwo <<\global \bassMusic >> }
654       >>
655       \context Lyrics = basses { s1 }
656       \context Lyrics = sopranos \lyricsto sopranos \sopWords
657       \context Lyrics = altos \lyricsto altos \altoWords
658       \context Lyrics = tenors \lyricsto tenors \tenorWords
659       \context Lyrics = basses \lyricsto basses \bassWords
660    >>
661
662    \layout {
663       \context {
664          % a little smaller so lyrics
665          % can be closer to the staff
666          \Staff minimumVerticalExtent = #'(-3 . 3)
667       }
668    }
669 }
670 @end lilypond
671
672
673 @subsection SATB vocal score and automatic piano reduction
674
675 This template adds an automatic piano reduction to the SATB vocal
676 score.  This demonstrates one of the strengths of LilyPond -- you
677 can use a music definition more than once.  If you make any changes
678 to the vocal notes (say, tenorMusic), then the changes will also
679 apply to the piano reduction.
680
681 @lilypond[quote,verbatim,raggedright]
682 \version "2.4.0"
683 global = {
684    \key c \major
685    \time 4/4
686 }
687
688 sopMusic = \relative c'' {
689    c4 c c8[( b)] c4
690 }
691 sopWords = \lyricmode {
692    hi hi hi hi
693 }
694
695 altoMusic = \relative c' {
696    e4 f d e
697 }
698 altoWords =\lyricmode {
699    ha ha ha ha
700 }
701
702 tenorMusic = \relative c' {
703    g4 a f g
704 }
705 tenorWords = \lyricmode {
706    hu hu hu hu
707 }
708 bassMusic = \relative c {
709    c4 c g c
710 }
711 bassWords = \lyricmode {
712    ho ho ho ho
713 }
714
715 \layout {
716   \context {
717          % a little smaller so lyrics
718          % can be closer to the staff
719          \Staff
720           minimumVerticalExtent = #'(-3 . 3)
721   }
722 }
723
724 <<
725   \context ChoirStaff
726   <<
727     \context Lyrics = sopranos { s1 }
728     \context Staff = women <<
729       \context Voice =
730         sopranos { \voiceOne << \global \sopMusic >> }
731       \context Voice =
732         altos { \voiceTwo << \global \altoMusic >> }
733     >>
734     \context Lyrics = altos { s1 }
735     \context Lyrics = tenors { s1 }
736     \context Staff = men <<
737       \clef bass
738       \context Voice =
739         tenors { \voiceOne <<\global \tenorMusic >> }
740       \context Voice =
741         basses { \voiceTwo <<\global \bassMusic >> }
742     >>
743     \context Lyrics = basses { s1 }
744     \context Lyrics = sopranos \lyricsto sopranos \sopWords
745     \context Lyrics = altos \lyricsto altos \altoWords
746     \context Lyrics = tenors \lyricsto tenors \tenorWords
747     \context Lyrics = basses \lyricsto basses \bassWords
748   >>
749   \new PianoStaff
750   <<
751     \new Staff <<
752       \set Staff.printPartCombineTexts = ##f
753       \partcombine
754       << \global \sopMusic >>
755       << \global \altoMusic >>
756     >>
757     \new Staff <<
758       \clef bass
759       \set Staff.printPartCombineTexts = ##f
760       \partcombine
761       << \global \tenorMusic >>
762       << \global \bassMusic >>
763     >>
764   >>
765 >>
766 @end lilypond
767
768
769 @c bad node name to avoid node name confict
770 @node Ancient notation templates
771 @section Ancient notation templates
772
773 @subsection Transcription of mensural music
774
775 When transcribing mensural music, an incipit at the beginning of the
776 piece is useful to indicate the original key and tempo.  While today
777 musicians are used to bar lines in order to faster recognize rhythmic
778 patterns, bar lines where not yet invented during the period of
779 mensural music; in fact, the meter often changed after every few
780 notes.  As a compromise, bar lines are often printed between the
781 staves rather than on the staves.
782
783 @lilypond[quote,verbatim,linewidth=11.0\cm]
784 \version "2.4.0"
785
786 global = {
787   % incipit
788   \once \override Score.SystemStartBracket #'transparent = ##t
789   \key f \major
790   \time 2/2
791   \once \override Staff.TimeSignature #'style = #'neomensural
792   \override Voice.NoteHead #'style = #'neomensural
793   \override Voice.Rest #'style = #'neomensural
794   \set Staff.printKeyCancellation = ##f
795   \cadenzaOn % turn off bar lines
796   \skip 1*10
797   \once \override Staff.BarLine #'transparent = ##f
798   \bar "||"
799   \skip 1*1 % need this extra \skip such that clef change comes
800             % after bar line
801   \bar ""
802
803   % main
804   \cadenzaOff % turn bar lines on again
805   \once \override Staff.Clef #'full-size-change = ##t
806   \set Staff.forceClef = ##t
807   \key g \major
808   \time 4/4
809   \override Voice.NoteHead #'style = #'default
810   \override Voice.Rest #'style = #'default
811
812   % FIXME: setting printKeyCancellation back to #t must not
813   % occur in the first bar after the incipit.  Dto. for forceClef.
814   % Therefore, we need an extra \skip.
815   \skip 1*1
816   \set Staff.printKeyCancellation = ##t
817   \set Staff.forceClef = ##f
818
819   \skip 1*5
820
821   % last bar contains a brevis (i.e., spans 2 bars);
822   % therefore do not draw this particular bar
823   \cadenzaOn
824   \skip 1*2
825   \cadenzaOff
826
827   % let finis bar go through all staves
828   \override Staff.BarLine #'transparent = ##f
829
830   % finis bar
831   \bar "|."
832 }
833
834 discantusNotes = {
835   \transpose c' c'' {
836     \set Staff.instrument = "Discantus  "
837
838     % incipit
839     \clef "neomensural-c1"
840     c'1. s2   % two bars
841     \skip 1*8 % eight bars
842     \skip 1*1 % one bar
843
844     % main
845     \clef "treble"
846     d'2. d'4 |
847     b e' d'2 |
848     c'4 e'4.( d'8 c' b |
849     a4) b a2 |
850     b4.( c'8 d'4) c'4 |
851     \once \override NoteHead #'transparent = ##t c'1 |
852     b\breve |
853   }
854 }
855
856 discantusLyrics = \lyricmode {
857   % incipit
858   IV-
859
860   % main
861   Ju -- bi -- |
862   la -- te De -- |
863   o, om --
864   nis ter -- |
865   ra, __ om- |
866   "..." |
867   -us. |
868 }
869
870 altusNotes = {
871   \transpose c' c'' {
872     \set Staff.instrument = "Altus  "
873
874     % incipit
875     \clef "neomensural-c3"
876     r1        % one bar
877     f1. s2    % two bars
878     \skip 1*7 % seven bars
879     \skip 1*1 % one bar
880
881     % main
882     \clef "treble"
883     r2 g2. e4 fis g | % two bars
884     a2 g4 e |
885     fis g4.( fis16 e fis4) |
886     g1 |
887     \once \override NoteHead #'transparent = ##t g1 |
888     g\breve |
889   }
890 }
891
892 altusLyrics = \lyricmode {
893   % incipit
894   IV-
895
896   % main
897   Ju -- bi -- la -- te | % two bars
898   De -- o, om -- |
899   nis ter -- ra, |
900   "..." |
901   -us. |
902 }
903
904 tenorNotes = {
905   \transpose c' c' {
906     \set Staff.instrument = "Tenor  "
907
908     % incipit
909     \clef "neomensural-c4"
910     r\longa   % four bars
911     r\breve   % two bars
912     r1        % one bar
913     c'1. s2   % two bars
914     \skip 1*1 % one bar
915     \skip 1*1 % one bar
916
917     % main
918     \clef "treble_8"
919     R1 |
920     R1 |
921     R1 |
922     r2 d'2. d'4 b e' | % two bars
923     \once \override NoteHead #'transparent = ##t e'1 |
924     d'\breve |
925   }
926 }
927
928 tenorLyrics = \lyricmode {
929   % incipit
930   IV-
931
932   % main
933   Ju -- bi -- la -- te | % two bars
934   "..." |
935   -us. |
936 }
937
938 bassusNotes = {
939   \transpose c' c' {
940     \set Staff.instrument = "Bassus  "
941
942     % incipit
943     \clef "bass"
944     r\maxima  % eight bars
945     f1. s2    % two bars
946     \skip 1*1 % one bar
947
948     % main
949     \clef "bass"
950     R1 |
951     R1 |
952     R1 |
953     R1 |
954     g2. e4 |
955     \once \override NoteHead #'transparent = ##t e1 |
956     g\breve |
957   }
958 }
959
960 bassusLyrics = \lyricmode {
961   % incipit
962   IV-
963
964   % main
965   Ju -- bi- |
966   "..." |
967   -us. |
968 }
969
970 \score {
971   \context StaffGroup = choirStaff <<
972     \context Voice =
973       discantusNotes << \global \discantusNotes >>
974     \context Lyrics =
975       discantusLyrics \lyricsto discantusNotes { \discantusLyrics }
976     \context Voice =
977       altusNotes << \global \altusNotes >>
978     \context Lyrics =
979       altusLyrics \lyricsto altusNotes { \altusLyrics }
980     \context Voice =
981       tenorNotes << \global \tenorNotes >>
982     \context Lyrics =
983       tenorLyrics \lyricsto tenorNotes { \tenorLyrics }
984     \context Voice =
985       bassusNotes << \global \bassusNotes >>
986     \context Lyrics =
987       bassusLyrics \lyricsto bassusNotes { \bassusLyrics }
988   >>
989   \layout {
990     \context {
991       \Score
992       \override BarLine #'transparent = ##t
993       \remove "System_start_delimiter_engraver"
994     }
995     \context {
996       \Voice
997       \override Slur #'transparent = ##t
998     }
999   }
1000 }
1001 @end lilypond
1002
1003
1004
1005 @node Jazz combo
1006 @section Jazz combo
1007
1008 This is a much more complicated template, for a jazz ensemble.  Note that all
1009 instruments are notated in @code{\key c \major}.  This refers to the key in
1010 concert pitch; LilyPond will automatically transpose the key if the music
1011 is within a @code{\transpose} section.
1012
1013 @c TODO must clean up this jazz combo example
1014 @c   - transpositions stated in names (ie "trumpet in Bb" or whatever)
1015 @c   - one global section, instead of "global" (time) and "key"
1016 @c   - does it need those wierd macros?  sl, nsl, etc.
1017 @c   - maybe ask Amelie Zapf to clean it up, or whether I should just
1018 @c     make whatever changes I feel like.
1019
1020 @c FIXME: produces a warning ; key change merge.
1021 @c The `linewidth' argument is for the \header.
1022
1023 @lilypond[quote,verbatim,raggedright,linewidth]
1024 \version "2.4.0"
1025 \header {
1026   title = "Song"
1027   subtitle = "(tune)"
1028   composer = "Me"
1029   meter = "moderato"
1030   piece = "Swing"
1031   tagline = "LilyPond example file by Amelie Zapf,
1032              Berlin 07/07/2003"
1033   texidoc = "Jazz tune for combo
1034              (horns, guitar, piano, bass, drums)."
1035 }
1036
1037 #(set-global-staff-size 16)
1038 \include "english.ly"
1039
1040 %%%%%%%%%%%% Some macros %%%%%%%%%%%%%%%%%%%
1041
1042 sl = {
1043   \override NoteHead #'style = #'slash
1044   \override Stem #'transparent = ##t
1045 }
1046 nsl = {
1047   \revert NoteHead #'style
1048   \revert Stem #'transparent
1049 }
1050 cr = \override NoteHead #'style = #'cross
1051 ncr = \revert NoteHead #'style
1052
1053 %% insert chord name style stuff here.
1054
1055 jzchords = { }
1056
1057
1058 %%%%%%%%%%%% Keys'n'thangs %%%%%%%%%%%%%%%%%
1059
1060 global = {
1061   \time 4/4
1062 }
1063
1064 Key = { \key c \major }
1065
1066 % ############ Horns ############
1067
1068 % ------ Trumpet ------
1069 trpt = \transpose c d \relative c'' {
1070   \Key
1071   c1 c c
1072 }
1073 trpharmony = \transpose c' d {
1074   \jzchords
1075 }
1076 trumpet = {
1077   \global
1078   \set Staff.instrument = #"Trumpet"
1079   \clef treble
1080   \context Staff <<
1081     \trpt
1082   >>
1083 }
1084
1085 % ------ Alto Saxophone ------
1086 alto = \transpose c a \relative c' {
1087   \Key
1088   c1 c c
1089 }
1090 altoharmony = \transpose c' a {
1091   \jzchords
1092 }
1093 altosax = {
1094   \global
1095   \set Staff.instrument = #"Alto Sax"
1096   \clef treble
1097   \context Staff <<
1098     \alto
1099   >>
1100 }
1101
1102 % ------ Baritone Saxophone ------
1103 bari = \transpose c a' \relative c {
1104   \Key
1105   c1 c \sl d4^"Solo" d d d \nsl
1106 }
1107 bariharmony = \transpose c' a \chordmode {
1108   \jzchords s1 s d2:maj e:m7
1109 }
1110 barisax = {
1111   \global
1112   \set Staff.instrument = #"Bari Sax"
1113   \clef treble
1114   \context Staff <<
1115     \bari
1116   >>
1117 }
1118
1119 % ------ Trombone ------
1120 tbone = \relative c {
1121   \Key
1122   c1 c c
1123 }
1124 tboneharmony = \chordmode {
1125   \jzchords
1126 }
1127 trombone = {
1128   \global
1129   \set Staff.instrument = #"Trombone"
1130   \clef bass
1131   \context Staff <<
1132     \tbone
1133   >>
1134 }
1135
1136 % ############ Rhythm Section #############
1137
1138 % ------ Guitar ------
1139 gtr = \relative c'' {
1140   \Key
1141   c1 \sl b4 b b b \nsl c1
1142 }
1143 gtrharmony = \chordmode {
1144   \jzchords
1145   s1 c2:min7+ d2:maj9
1146 }
1147 guitar = {
1148   \global
1149   \set Staff.instrument = #"Guitar"
1150   \clef treble
1151   \context Staff <<
1152     \gtr
1153   >>
1154 }
1155
1156 %% ------ Piano ------
1157 rhUpper = \relative c'' {
1158   \voiceOne
1159   \Key
1160   c1 c c
1161 }
1162 rhLower = \relative c' {
1163   \voiceTwo
1164   \Key
1165   e1 e e
1166 }
1167
1168 lhUpper = \relative c' {
1169   \voiceOne
1170   \Key
1171   g1 g g
1172 }
1173 lhLower = \relative c {
1174   \voiceTwo
1175   \Key
1176   c1 c c
1177 }
1178
1179 PianoRH = {
1180   \clef treble
1181   \global
1182   \set Staff.midiInstrument = "acoustic grand"
1183   \context Staff <<
1184     \context Voice = one \rhUpper
1185     \context Voice = two \rhLower
1186   >>
1187 }
1188 PianoLH = {
1189   \clef bass
1190   \global
1191   \set Staff.midiInstrument = "acoustic grand"
1192   \context Staff <<
1193     \context Voice = one \lhUpper
1194     \context Voice = two \lhLower
1195   >>
1196 }
1197
1198 piano = {
1199   \context PianoStaff <<
1200     \set PianoStaff.instrument = #"Piano"
1201     \context Staff = upper \PianoRH
1202     \context Staff = lower \PianoLH
1203   >>
1204 }
1205
1206 % ------ Bass Guitar ------
1207 Bass = \relative c {
1208   \Key
1209   c1 c c
1210 }
1211 bass = {
1212   \global
1213   \set Staff.instrument = #"Bass"
1214   \clef bass
1215   \context Staff <<
1216     \Bass
1217   >>
1218 }
1219
1220 % ------ Drums ------
1221 up = \drummode {
1222   hh4 <hh sn>4 hh <hh sn> hh <hh sn>4
1223   hh4 <hh sn>4
1224   hh4 <hh sn>4
1225   hh4 <hh sn>4
1226 }
1227
1228 down = \drummode {
1229   bd4 s bd s bd s bd s bd s bd s
1230 }
1231
1232 drumContents = {
1233   \global
1234   <<
1235     \set DrumStaff.instrument = #"Drums"
1236     \new DrumVoice { \voiceOne \up }
1237     \new DrumVoice { \voiceTwo \down }
1238   >>
1239 }
1240
1241 %%%%%%%%% It All Goes Together Here %%%%%%%%%%%%%%%%%%%%%%
1242
1243 \score {
1244   <<
1245     \context StaffGroup = horns <<
1246       \context Staff = trumpet \trumpet
1247       \context Staff = altosax \altosax
1248       \context ChordNames = barichords \bariharmony
1249       \context Staff = barisax \barisax
1250       \context Staff = trombone \trombone
1251     >>
1252
1253     \context StaffGroup = rhythm <<
1254       \context ChordNames = chords \gtrharmony
1255       \context Staff = guitar \guitar
1256       \context PianoStaff = piano \piano
1257       \context Staff = bass \bass
1258       \new DrumStaff { \drumContents }
1259     >>
1260   >>
1261
1262   \layout {
1263     \context { \RemoveEmptyStaffContext }
1264     \context {
1265       \Score
1266       \override BarNumber #'padding = #3
1267       \override RehearsalMark #'padding = #2
1268       skipBars = ##t
1269     }
1270   }
1271
1272   \midi { \tempo 4 = 75 }
1273 }
1274 @end lilypond
1275
1276 @node Other templates
1277 @section Other templates
1278 @subsection All headers
1279
1280 This template displays all available headers.  Some of them are only
1281 used in the Mutopia project; they don't affect the printed output at
1282 all.  They are used if you want the piece to be listed with different
1283 information in the Mutopia database than you wish to have printed on the
1284 music.  For example, Mutopia lists the composer of the famous D major
1285 violin concerto as TchaikovskyPI, whereas perhaps you wish to print
1286 "Petr Tchaikowski" on your music.
1287
1288 @ The `linewidth' is for \header.
1289 @lilypond[quote,verbatim,raggedright,linewidth]
1290 \version "2.4.0"
1291 \header {
1292   dedication = "dedication"
1293   title = "Title"
1294   subtitle = "Subtitle"
1295   subsubtitle = "Subsubtitle"
1296   composer = "Composer (xxxx-yyyy)"
1297   opus = "Opus 0"
1298   piece = "Piece I"
1299   instrument = "Instrument"
1300   arranger = "Arranger"
1301   poet = "Poet"
1302   texttranslator = "Translator"
1303   copyright = "public domain"
1304
1305   % These are headers used by the Mutopia Project
1306   % http://www.mutopiaproject.org/
1307   mutopiatitle = ""
1308   mutopiacomposer = ""
1309   mutopiapoet = ""
1310   mutopiainstrument = ""
1311   date = "composer's dates"
1312   source = "urtext "
1313   maintainer = "your name here"
1314   maintainerEmail = "your email here"
1315   maintainerWeb = "your home page"
1316   lastupdated = "2004/Aug/26"
1317 }
1318
1319 \score {
1320   \header {
1321     piece = "piece1"
1322     opus = "opus1"
1323   }
1324   { c'4 }
1325 }
1326
1327 \score {
1328   \header {
1329     piece = "piece2"
1330     opus = "opus2"
1331   }
1332   { c'4 }
1333 }
1334 @end lilypond
1335
1336 @subsection Gregorian template
1337
1338 This example demonstrates how to do modern transcriptions of Gregorian
1339 music.  Gregorian music has no measure, no stems; it uses only half and
1340 quarter notes, and two types of barlines, a short one indicating a rest,
1341 and a second one indicating a breath mark.
1342
1343 @lilypond[quote,verbatim,raggedright]
1344 barOne = { \once \override Staff.BarLine #'bar-size = #2
1345   \bar "|" }
1346 barTwo = { \once \override Staff.BarLine #'extra-offset = #'(0 . 2)
1347   \once \override Staff.BarLine #'bar-size = #2
1348   \bar "|" }
1349 chant = \relative c' {
1350   \set Score.timing = ##f
1351   \override Staff.Stem #'transparent = ##t
1352
1353   f4 a2 \barTwo
1354   g4 a2 f2 \barOne
1355   g4( f) f( g) a2
1356 }
1357 \score {
1358   \chant
1359   \layout{ }
1360   \midi { \tempo 4=60 }
1361 }
1362 @end lilypond
1363
1364 @subsection Bagpipe music
1365
1366 Here is an example of bagpipe music.  It demonstrates a big strength of
1367 LilyPond, compared to graphical score editors: in LilyPond, you can
1368 very easily reuse small segments of music without writing them out
1369 completely.  This template defines a large number of small segments
1370 (@code{taor}, @code{grip}, @code{thrd}, etc), which can be reused easily.
1371
1372 @c TODO - replace Bagpipe template with Andrew McNabb's work?
1373 @c  http://www.mcnabbs.org/andrew/linux/lilypond-ghb/
1374
1375 @lilypond[quote,verbatim]
1376 taor = { \grace { g32[ d' g e'] } }
1377 grip = { \grace { g32[ b g ]    } }
1378 thrd = { \grace { g32[ d' c']   } }
1379 birl = { \grace { g32[ a g]     } }
1380 gstd = { \grace { g'32[ d' g]   } }
1381 fgg  = { \grace { f32[ g'32]    } }
1382 dblb = { \grace { g'32[ b d']   } }
1383 dblc = { \grace { g'32[ c' d']  } }
1384 dble = { \grace { g'32[ e' f']  } }
1385 dblf = { \grace { g'32[ f' g']  } }
1386 dblg = { \grace { g'32[ f']     } }
1387 dbla = { \grace { a'32[ g']     } }
1388 lgg  = { \grace { g32  } }
1389 lag  = { \grace { a32  } }
1390 cg   = { \grace { c'32 } }
1391 eg   = { \grace { e'32 } }
1392 gg   = { \grace { g'32 } }
1393 dg   = { \grace { d'32 } }
1394 hag  = { \grace { a'32 } }
1395 gefg = { \grace { g'32[ e' f']  } }
1396 efg  = { \grace { e'32[ f']     } }
1397 gdcg = { \grace { g'32[ d' c']  } }
1398 gcdg = { \grace { g'32[ c' d']  } }
1399
1400 \transpose a a' {
1401   #(add-grace-property 'Voice 'Stem 'length 6)
1402   \time 6/8 \partial 4
1403   \tieUp
1404   \slurUp
1405
1406   f'4 |
1407   \gg f'4 e'8 \thrd d'4. |
1408   \eg a4.(a4) d'8 |
1409   \gg d'4 f'8 \dble e'4. ( | \noBreak
1410   e'8) d'4 \gg d'4 e'8 |
1411
1412   \break
1413   \time 9/8
1414   \dblf f'2.( f'4) d'8 |
1415   \time 6/8
1416   \dblg g'4 a'8 \gg a'4. |
1417   \thrd d'4.( d'4) \eg a8 |
1418   \time 9/8
1419   \dble e'4 \lag e'8 \gg e'16[ d'8. e'8] \gg f'4 g'8 |
1420
1421   \break
1422   \time 6/8
1423   \gg f'4 e'8 \thrd d'4. |
1424   \eg a4.( a4) d'8 |
1425   \dblg g'4 a'8 \gg a'4. |
1426   \thrd d'4.( d'4) f'8 |
1427
1428   \break
1429   \dblg g'4 e'8( e'8) \dblf f'8.[ e'16] |
1430   \thrd d'4.( d'4) \cg d'8 |
1431   \gg c'4 e'8 \thrd d'4.( |
1432   d'4.) \gdcg d'4.
1433 }
1434 @end lilypond
1435
1436
1437 @node Lilypond-book templates
1438 @section Lilypond-book templates
1439
1440 These templates are for use with @code{lilypond-book}.  If you're not familiar
1441 with this program, please refer to @ref{LilyPond-book}.
1442
1443 @subsection LaTeX
1444
1445 You can include LilyPond fragments in a LaTeX document.
1446
1447 @example
1448 \documentclass[]@{article@}
1449 \begin@{document@}
1450
1451 Normal LaTeX text.
1452
1453 \begin@{lilypond@}
1454 \relative c'' @{
1455 a4 b c d
1456 @}
1457 \end@{lilypond@}
1458
1459 More LaTeX text.
1460
1461 \begin@{lilypond@}
1462 \relative c'' @{
1463 d4 c b a
1464 @}
1465 \end@{lilypond@}
1466 \end@{document@}
1467 @end example
1468
1469 @subsection Texinfo
1470
1471 You can include LilyPond fragments in Texinfo; in fact, this entire manual
1472 is written in Texinfo.
1473
1474 @example
1475 \input texinfo
1476 @@node Top
1477
1478 Texinfo text
1479
1480 @@lilypond[verbatim,fragment,raggedright]
1481 a4 b c d
1482 @@end lilypond
1483
1484 More Texinfo text
1485
1486 @@lilypond[verbatim,fragment,raggedright]
1487 d4 c b a
1488 @@end lilypond
1489
1490 @@bye
1491 @end example