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