]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/examples.itely
Misc doc additions.
[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 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 \score {
716 <<
717   \context ChoirStaff
718   <<
719     \context Lyrics = sopranos { s1 }
720     \context Staff = women <<
721       \context Voice =
722         sopranos { \voiceOne << \global \sopMusic >> }
723       \context Voice =
724         altos { \voiceTwo << \global \altoMusic >> }
725     >>
726     \context Lyrics = altos { s1 }
727     \context Lyrics = tenors { s1 }
728     \context Staff = men <<
729       \clef bass
730       \context Voice =
731         tenors { \voiceOne <<\global \tenorMusic >> }
732       \context Voice =
733         basses { \voiceTwo <<\global \bassMusic >> }
734     >>
735     \context Lyrics = basses { s1 }
736     \context Lyrics = sopranos \lyricsto sopranos \sopWords
737     \context Lyrics = altos \lyricsto altos \altoWords
738     \context Lyrics = tenors \lyricsto tenors \tenorWords
739     \context Lyrics = basses \lyricsto basses \bassWords
740   >>
741   \new PianoStaff
742   <<
743     \new Staff <<
744     \context Lyrics = tenors \lyricsto tenors \tenorWords
745     \context Lyrics = basses \lyricsto basses \bassWords
746   >>
747   \new PianoStaff
748   <<
749     \new Staff <<
750       \set Staff.printPartCombineTexts = ##f
751       \partcombine
752       << \global \sopMusic >>
753       << \global \altoMusic >>
754     >>
755     \new Staff <<
756       \clef bass
757       \set Staff.printPartCombineTexts = ##f
758       \partcombine
759       << \global \tenorMusic >>
760       << \global \bassMusic >>
761     >>
762   >>
763 >>
764    
765    \layout {
766       \context {
767          % a little smaller so lyrics
768          % can be closer to the staff
769          \Staff minimumVerticalExtent = #'(-3 . 3)
770       }
771    }
772 }
773 @end lilypond
774
775
776 @c bad node name to avoid node name confict
777 @node Ancient notation templates
778 @section Ancient notation templates
779
780 @subsection Transcription of mensural music
781
782 When transcribing mensural music, an incipit at the beginning of the
783 piece is useful to indicate the original key and tempo.  While today
784 musicians are used to bar lines in order to faster recognize rhythmic
785 patterns, bar lines where not yet invented during the period of
786 mensural music; in fact, the meter often changed after every few
787 notes.  As a compromise, bar lines are often printed between the
788 staves rather than on the staves.
789
790 @lilypond[quote,verbatim,linewidth=11.0\cm]
791 \version "2.4.0"
792
793 global = {
794   % incipit
795   \once \override Score.SystemStartBracket #'transparent = ##t
796   \key f \major
797   \time 2/2
798   \once \override Staff.TimeSignature #'style = #'neomensural
799   \override Voice.NoteHead #'style = #'neomensural
800   \override Voice.Rest #'style = #'neomensural
801   \set Staff.printKeyCancellation = ##f
802   \cadenzaOn % turn off bar lines
803   \skip 1*10
804   \once \override Staff.BarLine #'transparent = ##f
805   \bar "||"
806   \skip 1*1 % need this extra \skip such that clef change comes
807             % after bar line
808   \bar ""
809
810   % main
811   \cadenzaOff % turn bar lines on again
812   \once \override Staff.Clef #'full-size-change = ##t
813   \set Staff.forceClef = ##t
814   \key g \major
815   \time 4/4
816   \override Voice.NoteHead #'style = #'default
817   \override Voice.Rest #'style = #'default
818
819   % FIXME: setting printKeyCancellation back to #t must not
820   % occur in the first bar after the incipit.  Dto. for forceClef.
821   % Therefore, we need an extra \skip.
822   \skip 1*1
823   \set Staff.printKeyCancellation = ##t
824   \set Staff.forceClef = ##f
825
826   \skip 1*5
827
828   % last bar contains a brevis (i.e., spans 2 bars);
829   % therefore do not draw this particular bar
830   \cadenzaOn
831   \skip 1*2
832   \cadenzaOff
833
834   % let finis bar go through all staves
835   \override Staff.BarLine #'transparent = ##f
836
837   % finis bar
838   \bar "|."
839 }
840
841 discantusNotes = {
842   \transpose c' c'' {
843     \set Staff.instrument = "Discantus  "
844
845     % incipit
846     \clef "neomensural-c1"
847     c'1. s2   % two bars
848     \skip 1*8 % eight bars
849     \skip 1*1 % one bar
850
851     % main
852     \clef "treble"
853     d'2. d'4 |
854     b e' d'2 |
855     c'4 e'4.( d'8 c' b |
856     a4) b a2 |
857     b4.( c'8 d'4) c'4 |
858     \once \override NoteHead #'transparent = ##t c'1 |
859     b\breve |
860   }
861 }
862
863 discantusLyrics = \lyricmode {
864   % incipit
865   IV-
866
867   % main
868   Ju -- bi -- |
869   la -- te De -- |
870   o, om --
871   nis ter -- |
872   ra, __ om- |
873   "..." |
874   -us. |
875 }
876
877 altusNotes = {
878   \transpose c' c'' {
879     \set Staff.instrument = "Altus  "
880
881     % incipit
882     \clef "neomensural-c3"
883     r1        % one bar
884     f1. s2    % two bars
885     \skip 1*7 % seven bars
886     \skip 1*1 % one bar
887
888     % main
889     \clef "treble"
890     r2 g2. e4 fis g | % two bars
891     a2 g4 e |
892     fis g4.( fis16 e fis4) |
893     g1 |
894     \once \override NoteHead #'transparent = ##t g1 |
895     g\breve |
896   }
897 }
898
899 altusLyrics = \lyricmode {
900   % incipit
901   IV-
902
903   % main
904   Ju -- bi -- la -- te | % two bars
905   De -- o, om -- |
906   nis ter -- ra, |
907   "..." |
908   -us. |
909 }
910
911 tenorNotes = {
912   \transpose c' c' {
913     \set Staff.instrument = "Tenor  "
914
915     % incipit
916     \clef "neomensural-c4"
917     r\longa   % four bars
918     r\breve   % two bars
919     r1        % one bar
920     c'1. s2   % two bars
921     \skip 1*1 % one bar
922     \skip 1*1 % one bar
923
924     % main
925     \clef "treble_8"
926     R1 |
927     R1 |
928     R1 |
929     r2 d'2. d'4 b e' | % two bars
930     \once \override NoteHead #'transparent = ##t e'1 |
931     d'\breve |
932   }
933 }
934
935 tenorLyrics = \lyricmode {
936   % incipit
937   IV-
938
939   % main
940   Ju -- bi -- la -- te | % two bars
941   "..." |
942   -us. |
943 }
944
945 bassusNotes = {
946   \transpose c' c' {
947     \set Staff.instrument = "Bassus  "
948
949     % incipit
950     \clef "bass"
951     r\maxima  % eight bars
952     f1. s2    % two bars
953     \skip 1*1 % one bar
954
955     % main
956     \clef "bass"
957     R1 |
958     R1 |
959     R1 |
960     R1 |
961     g2. e4 |
962     \once \override NoteHead #'transparent = ##t e1 |
963     g\breve |
964   }
965 }
966
967 bassusLyrics = \lyricmode {
968   % incipit
969   IV-
970
971   % main
972   Ju -- bi- |
973   "..." |
974   -us. |
975 }
976
977 \score {
978   \context StaffGroup = choirStaff <<
979     \context Voice =
980       discantusNotes << \global \discantusNotes >>
981     \context Lyrics =
982       discantusLyrics \lyricsto discantusNotes { \discantusLyrics }
983     \context Voice =
984       altusNotes << \global \altusNotes >>
985     \context Lyrics =
986       altusLyrics \lyricsto altusNotes { \altusLyrics }
987     \context Voice =
988       tenorNotes << \global \tenorNotes >>
989     \context Lyrics =
990       tenorLyrics \lyricsto tenorNotes { \tenorLyrics }
991     \context Voice =
992       bassusNotes << \global \bassusNotes >>
993     \context Lyrics =
994       bassusLyrics \lyricsto bassusNotes { \bassusLyrics }
995   >>
996   \layout {
997     \context {
998       \Score
999       \override BarLine #'transparent = ##t
1000       \remove "System_start_delimiter_engraver"
1001     }
1002     \context {
1003       \Voice
1004       \override Slur #'transparent = ##t
1005     }
1006   }
1007 }
1008 @end lilypond
1009
1010
1011
1012 @node Jazz combo
1013 @section Jazz combo
1014
1015 This is a much more complicated template, for a jazz ensemble.  Note that all
1016 instruments are notated in @code{\key c \major}.  This refers to the key in
1017 concert pitch; LilyPond will automatically transpose the key if the music
1018 is within a @code{\transpose} section.
1019
1020 @c TODO must clean up this jazz combo example
1021 @c   - transpositions stated in names (ie "trumpet in Bb" or whatever)
1022 @c   - one global section, instead of "global" (time) and "key"
1023 @c   - does it need those wierd macros?  sl, nsl, etc.
1024 @c   - maybe ask Amelie Zapf to clean it up, or whether I should just
1025 @c     make whatever changes I feel like.
1026
1027 @c FIXME: produces a warning ; key change merge.
1028 @c The `linewidth' argument is for the \header.
1029
1030 @lilypond[quote,verbatim,raggedright,linewidth]
1031 \version "2.4.0"
1032 \header {
1033   title = "Song"
1034   subtitle = "(tune)"
1035   composer = "Me"
1036   meter = "moderato"
1037   piece = "Swing"
1038   tagline = "LilyPond example file by Amelie Zapf,
1039              Berlin 07/07/2003"
1040   texidoc = "Jazz tune for combo
1041              (horns, guitar, piano, bass, drums)."
1042 }
1043
1044 #(set-global-staff-size 16)
1045 \include "english.ly"
1046
1047 %%%%%%%%%%%% Some macros %%%%%%%%%%%%%%%%%%%
1048
1049 sl = {
1050   \override NoteHead #'style = #'slash
1051   \override Stem #'transparent = ##t
1052 }
1053 nsl = {
1054   \revert NoteHead #'style
1055   \revert Stem #'transparent
1056 }
1057 cr = \override NoteHead #'style = #'cross
1058 ncr = \revert NoteHead #'style
1059
1060 %% insert chord name style stuff here.
1061
1062 jzchords = { }
1063
1064
1065 %%%%%%%%%%%% Keys'n'thangs %%%%%%%%%%%%%%%%%
1066
1067 global = {
1068   \time 4/4
1069 }
1070
1071 Key = { \key c \major }
1072
1073 % ############ Horns ############
1074
1075 % ------ Trumpet ------
1076 trpt = \transpose c d \relative c'' {
1077   \Key
1078   c1 c c
1079 }
1080 trpharmony = \transpose c' d {
1081   \jzchords
1082 }
1083 trumpet = {
1084   \global
1085   \set Staff.instrument = #"Trumpet"
1086   \clef treble
1087   \context Staff <<
1088     \trpt
1089   >>
1090 }
1091
1092 % ------ Alto Saxophone ------
1093 alto = \transpose c a \relative c' {
1094   \Key
1095   c1 c c
1096 }
1097 altoharmony = \transpose c' a {
1098   \jzchords
1099 }
1100 altosax = {
1101   \global
1102   \set Staff.instrument = #"Alto Sax"
1103   \clef treble
1104   \context Staff <<
1105     \alto
1106   >>
1107 }
1108
1109 % ------ Baritone Saxophone ------
1110 bari = \transpose c a' \relative c {
1111   \Key
1112   c1 c \sl d4^"Solo" d d d \nsl
1113 }
1114 bariharmony = \transpose c' a \chordmode {
1115   \jzchords s1 s d2:maj e:m7
1116 }
1117 barisax = {
1118   \global
1119   \set Staff.instrument = #"Bari Sax"
1120   \clef treble
1121   \context Staff <<
1122     \bari
1123   >>
1124 }
1125
1126 % ------ Trombone ------
1127 tbone = \relative c {
1128   \Key
1129   c1 c c
1130 }
1131 tboneharmony = \chordmode {
1132   \jzchords
1133 }
1134 trombone = {
1135   \global
1136   \set Staff.instrument = #"Trombone"
1137   \clef bass
1138   \context Staff <<
1139     \tbone
1140   >>
1141 }
1142
1143 % ############ Rhythm Section #############
1144
1145 % ------ Guitar ------
1146 gtr = \relative c'' {
1147   \Key
1148   c1 \sl b4 b b b \nsl c1
1149 }
1150 gtrharmony = \chordmode {
1151   \jzchords
1152   s1 c2:min7+ d2:maj9
1153 }
1154 guitar = {
1155   \global
1156   \set Staff.instrument = #"Guitar"
1157   \clef treble
1158   \context Staff <<
1159     \gtr
1160   >>
1161 }
1162
1163 %% ------ Piano ------
1164 rhUpper = \relative c'' {
1165   \voiceOne
1166   \Key
1167   c1 c c
1168 }
1169 rhLower = \relative c' {
1170   \voiceTwo
1171   \Key
1172   e1 e e
1173 }
1174
1175 lhUpper = \relative c' {
1176   \voiceOne
1177   \Key
1178   g1 g g
1179 }
1180 lhLower = \relative c {
1181   \voiceTwo
1182   \Key
1183   c1 c c
1184 }
1185
1186 PianoRH = {
1187   \clef treble
1188   \global
1189   \set Staff.midiInstrument = "acoustic grand"
1190   \context Staff <<
1191     \context Voice = one \rhUpper
1192     \context Voice = two \rhLower
1193   >>
1194 }
1195 PianoLH = {
1196   \clef bass
1197   \global
1198   \set Staff.midiInstrument = "acoustic grand"
1199   \context Staff <<
1200     \context Voice = one \lhUpper
1201     \context Voice = two \lhLower
1202   >>
1203 }
1204
1205 piano = {
1206   \context PianoStaff <<
1207     \set PianoStaff.instrument = #"Piano"
1208     \context Staff = upper \PianoRH
1209     \context Staff = lower \PianoLH
1210   >>
1211 }
1212
1213 % ------ Bass Guitar ------
1214 Bass = \relative c {
1215   \Key
1216   c1 c c
1217 }
1218 bass = {
1219   \global
1220   \set Staff.instrument = #"Bass"
1221   \clef bass
1222   \context Staff <<
1223     \Bass
1224   >>
1225 }
1226
1227 % ------ Drums ------
1228 up = \drummode {
1229   hh4 <hh sn>4 hh <hh sn> hh <hh sn>4
1230   hh4 <hh sn>4
1231   hh4 <hh sn>4
1232   hh4 <hh sn>4
1233 }
1234
1235 down = \drummode {
1236   bd4 s bd s bd s bd s bd s bd s
1237 }
1238
1239 drumContents = {
1240   \global
1241   <<
1242     \set DrumStaff.instrument = #"Drums"
1243     \new DrumVoice { \voiceOne \up }
1244     \new DrumVoice { \voiceTwo \down }
1245   >>
1246 }
1247
1248 %%%%%%%%% It All Goes Together Here %%%%%%%%%%%%%%%%%%%%%%
1249
1250 \score {
1251   <<
1252     \context StaffGroup = horns <<
1253       \context Staff = trumpet \trumpet
1254       \context Staff = altosax \altosax
1255       \context ChordNames = barichords \bariharmony
1256       \context Staff = barisax \barisax
1257       \context Staff = trombone \trombone
1258     >>
1259
1260     \context StaffGroup = rhythm <<
1261       \context ChordNames = chords \gtrharmony
1262       \context Staff = guitar \guitar
1263       \context PianoStaff = piano \piano
1264       \context Staff = bass \bass
1265       \new DrumStaff { \drumContents }
1266     >>
1267   >>
1268
1269   \layout {
1270     \context { \RemoveEmptyStaffContext }
1271     \context {
1272       \Score
1273       \override BarNumber #'padding = #3
1274       \override RehearsalMark #'padding = #2
1275       skipBars = ##t
1276     }
1277   }
1278
1279   \midi { \tempo 4 = 75 }
1280 }
1281 @end lilypond
1282
1283 @node Other templates
1284 @section Other templates
1285 @subsection All headers
1286
1287 This template displays all available headers.  Some of them are only
1288 used in the Mutopia project; they don't affect the printed output at
1289 all.  They are used if you want the piece to be listed with different
1290 information in the Mutopia database than you wish to have printed on the
1291 music.  For example, Mutopia lists the composer of the famous D major
1292 violin concerto as TchaikovskyPI, whereas perhaps you wish to print
1293 "Petr Tchaikowski" on your music.
1294
1295 @ The `linewidth' is for \header.
1296 @lilypond[quote,verbatim,raggedright,linewidth]
1297 \version "2.4.0"
1298 \header {
1299   dedication = "dedication"
1300   title = "Title"
1301   subtitle = "Subtitle"
1302   subsubtitle = "Subsubtitle"
1303   composer = "Composer (xxxx-yyyy)"
1304   opus = "Opus 0"
1305   piece = "Piece I"
1306   instrument = "Instrument"
1307   arranger = "Arranger"
1308   poet = "Poet"
1309   texttranslator = "Translator"
1310   copyright = "public domain"
1311
1312   % These are headers used by the Mutopia Project
1313   % http://www.mutopiaproject.org/
1314   mutopiatitle = ""
1315   mutopiacomposer = ""
1316   mutopiapoet = ""
1317   mutopiainstrument = ""
1318   date = "composer's dates"
1319   source = "urtext "
1320   maintainer = "your name here"
1321   maintainerEmail = "your email here"
1322   maintainerWeb = "your home page"
1323   lastupdated = "2004/Aug/26"
1324 }
1325
1326 \score {
1327   \header {
1328     piece = "piece1"
1329     opus = "opus1"
1330   }
1331   { c'4 }
1332 }
1333
1334 \score {
1335   \header {
1336     piece = "piece2"
1337     opus = "opus2"
1338   }
1339   { c'4 }
1340 }
1341 @end lilypond
1342
1343 @subsection Gregorian template
1344
1345 This example demonstrates how to do modern transcriptions of Gregorian
1346 music.  Gregorian music has no measure, no stems; it uses only half and
1347 quarter notes, and two types of barlines, a short one indicating a rest,
1348 and a second one indicating a breath mark.
1349
1350 @lilypond[quote,verbatim,raggedright]
1351 barOne = { \once \override Staff.BarLine #'bar-size = #2
1352   \bar "|" }
1353 barTwo = { \once \override Staff.BarLine #'extra-offset = #'(0 . 2)
1354   \once \override Staff.BarLine #'bar-size = #2
1355   \bar "|" }
1356 chant = \relative c' {
1357   \set Score.timing = ##f
1358   \override Staff.Stem #'transparent = ##t
1359
1360   f4 a2 \barTwo
1361   g4 a2 f2 \barOne
1362   g4( f) f( g) a2
1363 }
1364 \score {
1365   \chant
1366   \layout{ }
1367   \midi { \tempo 4=60 }
1368 }
1369 @end lilypond
1370
1371 @subsection Bagpipe music
1372
1373 Here is an example of bagpipe music.  It demonstrates a big strength of
1374 LilyPond, compared to graphical score editors: in LilyPond, you can
1375 very easily reuse small segments of music without writing them out
1376 completely.  This template defines a large number of small segments
1377 (@code{taor}, @code{grip}, @code{thrd}, etc), which can be reused easily.
1378
1379 @c TODO - replace Bagpipe template with Andrew McNabb's work?
1380 @c  http://www.mcnabbs.org/andrew/linux/lilypond-ghb/
1381
1382 @lilypond[quote,verbatim]
1383 taor = { \grace { g32[ d' g e'] } }
1384 grip = { \grace { g32[ b g ]    } }
1385 thrd = { \grace { g32[ d' c']   } }
1386 birl = { \grace { g32[ a g]     } }
1387 gstd = { \grace { g'32[ d' g]   } }
1388 fgg  = { \grace { f32[ g'32]    } }
1389 dblb = { \grace { g'32[ b d']   } }
1390 dblc = { \grace { g'32[ c' d']  } }
1391 dble = { \grace { g'32[ e' f']  } }
1392 dblf = { \grace { g'32[ f' g']  } }
1393 dblg = { \grace { g'32[ f']     } }
1394 dbla = { \grace { a'32[ g']     } }
1395 lgg  = { \grace { g32  } }
1396 lag  = { \grace { a32  } }
1397 cg   = { \grace { c'32 } }
1398 eg   = { \grace { e'32 } }
1399 gg   = { \grace { g'32 } }
1400 dg   = { \grace { d'32 } }
1401 hag  = { \grace { a'32 } }
1402 gefg = { \grace { g'32[ e' f']  } }
1403 efg  = { \grace { e'32[ f']     } }
1404 gdcg = { \grace { g'32[ d' c']  } }
1405 gcdg = { \grace { g'32[ c' d']  } }
1406
1407 \transpose a a' {
1408   #(add-grace-property 'Voice 'Stem 'length 6)
1409   \time 6/8 \partial 4
1410   \tieUp
1411   \slurUp
1412
1413   f'4 |
1414   \gg f'4 e'8 \thrd d'4. |
1415   \eg a4.(a4) d'8 |
1416   \gg d'4 f'8 \dble e'4. ( | \noBreak
1417   e'8) d'4 \gg d'4 e'8 |
1418
1419   \break
1420   \time 9/8
1421   \dblf f'2.( f'4) d'8 |
1422   \time 6/8
1423   \dblg g'4 a'8 \gg a'4. |
1424   \thrd d'4.( d'4) \eg a8 |
1425   \time 9/8
1426   \dble e'4 \lag e'8 \gg e'16[ d'8. e'8] \gg f'4 g'8 |
1427
1428   \break
1429   \time 6/8
1430   \gg f'4 e'8 \thrd d'4. |
1431   \eg a4.( a4) d'8 |
1432   \dblg g'4 a'8 \gg a'4. |
1433   \thrd d'4.( d'4) f'8 |
1434
1435   \break
1436   \dblg g'4 e'8( e'8) \dblf f'8.[ e'16] |
1437   \thrd d'4.( d'4) \cg d'8 |
1438   \gg c'4 e'8 \thrd d'4.( |
1439   d'4.) \gdcg d'4.
1440 }
1441 @end lilypond
1442
1443
1444 @node Lilypond-book templates
1445 @section Lilypond-book templates
1446
1447 These templates are for use with @code{lilypond-book}.  If you're not familiar
1448 with this program, please refer to @ref{LilyPond-book}.
1449
1450 @subsection LaTeX
1451
1452 You can include LilyPond fragments in a LaTeX document.
1453
1454 @example
1455 \documentclass[]@{article@}
1456 \begin@{document@}
1457
1458 Normal LaTeX text.
1459
1460 \begin@{lilypond@}
1461 \relative c'' @{
1462 a4 b c d
1463 @}
1464 \end@{lilypond@}
1465
1466 More LaTeX text.
1467
1468 \begin@{lilypond@}
1469 \relative c'' @{
1470 d4 c b a
1471 @}
1472 \end@{lilypond@}
1473 \end@{document@}
1474 @end example
1475
1476 @subsection Texinfo
1477
1478 You can include LilyPond fragments in Texinfo; in fact, this entire manual
1479 is written in Texinfo.
1480
1481 @example
1482 \input texinfo
1483 @@node Top
1484
1485 Texinfo text
1486
1487 @@lilypond[verbatim,fragment,raggedright]
1488 a4 b c d
1489 @@end lilypond
1490
1491 More Texinfo text
1492
1493 @@lilypond[verbatim,fragment,raggedright]
1494 d4 c b a
1495 @@end lilypond
1496
1497 @@bye
1498 @end example