]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/examples.itely
patches by John Williams:
[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 }
415 \score {
416   \context PianoStaff <<
417     \context Staff=upper << \upper \dynamics >>
418     \context Staff=lower << \lower \dynamics >>
419     \context Dynamics=pedal \pedal
420   >>
421   \midi {
422     \context {
423       \type "Performer_group_performer"
424       \name Dynamics
425       \consists "Piano_pedal_performer"
426     }
427     \context {
428       \PianoStaff
429       \accepts Dynamics
430     }
431   }
432 }
433 @end lilypond
434
435
436 @node String quartet
437 @section String quartet
438 @subsection String quartet
439
440 This template demonstrates a string quartet.  It also uses a @code{\global}
441 section for time and key signatures.
442
443 @lilypond[quote,verbatim,raggedright]
444 \version "2.4.0"
445
446 global= {
447   \time 4/4
448   \key c \major
449 }
450
451 violinOne = \new Voice { \relative c''{
452   \set Staff.instrument = "Violin 1 "
453
454   c2 d e1
455
456 \bar "|." }}
457 violinTwo = \new Voice { \relative c''{
458   \set Staff.instrument = "Violin 2 "
459
460   g2 f e1
461
462 \bar "|." }}
463 viola = \new Voice { \relative c' {
464   \set Staff.instrument = "Viola "
465   \clef alto
466
467   e2 d c1
468
469 \bar "|." }}
470 cello = \new Voice { \relative c' {
471   \set Staff.instrument = "Cello     "
472   \clef bass
473
474   c2 b a1
475
476 \bar "|."}}
477
478 \score {
479    \new StaffGroup <<
480       \new Staff << \global \violinOne >>
481       \new Staff << \global \violinTwo >>
482       \new Staff << \global \viola >>
483       \new Staff << \global \cello >>
484    >>
485    \layout { }
486    \midi { \tempo 4=60}
487 }
488 @end lilypond
489
490 @subsection String quartet parts
491
492 The previous example produces a nice string quartet, but what if you
493 needed to print parts?  This template demonstrates how to use the
494 @code{\tag} feature to easily split a piece into individual parts.
495
496 You need to split this template into separate files; the filenames
497 are contained in comments at the beginning of each file.  @code{piece.ly}
498 contains all the music definitions.  The other files -- @code{score.ly},
499 @code{vn1.ly}, @code{vn2.ly}, @code{vla.ly}, and
500 @code{vlc.ly} -- produce the appropiate part.
501
502 @verbatim
503 %%%%% piece.ly
504 \version "2.4.0"
505
506 global= {
507   \time 4/4
508   \key c \major
509 }
510
511 Violinone = \new Voice { \relative c''{
512   \set Staff.instrument = "Violin 1 "
513
514   c2 d e1
515
516 \bar "|." }}   %*********************************
517 Violintwo = \new Voice { \relative c''{
518   \set Staff.instrument = "Violin 2 "
519
520   g2 f e1
521
522 \bar "|." }}   %*********************************
523 Viola = \new Voice { \relative c' {
524   \set Staff.instrument = "Viola "
525   \clef alto
526
527   e2 d c1
528
529 \bar "|." }}   %*********************************
530 Cello = \new Voice { \relative c' {
531   \set Staff.instrument = "Cello     "
532   \clef bass
533
534   c2 b a1
535
536 \bar "|."}}   %**********************************
537
538 music = {
539   <<
540     \tag #'(score vn1) \new Staff { << \global \Violinone >> }
541     \tag #'(score vn2) \new Staff { << \global \Violintwo>> }
542     \tag #'(score vla) \new Staff { << \global \Viola>> }
543     \tag #'(score vlc) \new Staff { << \global \Cello>> }
544   >>
545 }
546
547
548
549 %%%%% score.ly
550 \version "2.4.0"
551 \include "piece.ly"
552 #(set-global-staff-size 14)
553 \score {
554   \new StaffGroup \keepWithTag #'score \music
555   \layout { }
556   \midi { \tempo 4 = 60 }
557 }
558
559
560 %%%%% vn1.ly
561 \version "2.4.0"
562 \include "piece.ly"
563 \score { 
564   \keepWithTag #'vn1 \music
565   \layout { }
566 }
567
568
569 %%%%% vn2.ly
570 \version "2.4.0"
571 \include "piece.ly"
572 \score { 
573   \keepWithTag #'vn2 \music
574   \layout { }
575 }
576
577
578 %%%%% vla.ly
579 \version "2.4.0"
580 \include "piece.ly"
581 \score { 
582   \keepWithTag #'vla \music
583   \layout { }
584 }
585
586
587 %%%%% vlc.ly
588 \version "2.4.0"
589 \include "piece.ly"
590 \score { 
591   \keepWithTag #'vlc \music
592   \layout { }
593 }
594 @end verbatim
595
596
597 @node Vocal ensembles
598 @section Vocal ensembles
599
600 @subsection SATB vocal score
601
602 Here is a standard four-part SATB vocal score.  With larger ensembles,
603 it's often useful to include a section which is included in all
604 parts.  For example, the time signature and key signatures are almost
605 always the same for all parts.
606
607 @lilypond[quote,verbatim,raggedright]
608 \version "2.4.0"
609 global = {
610    \key c \major
611    \time 4/4
612 }
613
614 sopMusic = \relative c'' {
615    c4 c c8[( b)] c4
616 }
617 sopWords = \lyricmode {
618    hi hi hi hi
619 }
620
621 altoMusic = \relative c' {
622    e4 f d e
623 }
624 altoWords =\lyricmode {
625    ha ha ha ha
626 }
627
628 tenorMusic = \relative c' {
629    g4 a f g
630 }
631 tenorWords = \lyricmode {
632    hu hu hu hu
633 }
634
635 bassMusic = \relative c {
636    c4 c g c
637 }
638 bassWords = \lyricmode {
639    ho ho ho ho
640 }
641
642 \score {
643    \context ChoirStaff <<
644       \context Lyrics = sopranos { s1 }
645       \context Staff = women <<
646          \context Voice =
647            sopranos { \voiceOne << \global \sopMusic >> }
648          \context Voice =
649            altos { \voiceTwo << \global \altoMusic >> }
650       >>
651       \context Lyrics = altos { s1 }
652       \context Lyrics = tenors { s1 }
653       \context Staff = men <<
654          \clef bass
655          \context Voice =
656            tenors { \voiceOne <<\global \tenorMusic >> }
657          \context Voice =
658            basses { \voiceTwo <<\global \bassMusic >> }
659       >>
660       \context Lyrics = basses { s1 }
661       \context Lyrics = sopranos \lyricsto sopranos \sopWords
662       \context Lyrics = altos \lyricsto altos \altoWords
663       \context Lyrics = tenors \lyricsto tenors \tenorWords
664       \context Lyrics = basses \lyricsto basses \bassWords
665    >>
666
667    \layout {
668       \context {
669          % a little smaller so lyrics
670          % can be closer to the staff
671          \Staff minimumVerticalExtent = #'(-3 . 3)
672       }
673    }
674 }
675 @end lilypond
676
677
678 @subsection SATB vocal score and automatic piano reduction
679
680 This template adds an automatic piano reduction to the SATB vocal
681 score.  This demonstrates one of the strengths of LilyPond -- you
682 can use a music definition more than once.  If you make any changes
683 to the vocal notes (say, tenorMusic), then the changes will also
684 apply to the piano reduction.
685
686 @lilypond[quote,verbatim,raggedright]
687 \version "2.4.0"
688 global = {
689    \key c \major
690    \time 4/4
691 }
692
693 sopMusic = \relative c'' {
694    c4 c c8[( b)] c4
695 }
696 sopWords = \lyricmode {
697    hi hi hi hi
698 }
699
700 altoMusic = \relative c' {
701    e4 f d e
702 }
703 altoWords =\lyricmode {
704    ha ha ha ha
705 }
706
707 tenorMusic = \relative c' {
708    g4 a f g
709 }
710 tenorWords = \lyricmode {
711    hu hu hu hu
712 }
713 bassMusic = \relative c {
714    c4 c g c
715 }
716 bassWords = \lyricmode {
717    ho ho ho ho
718 }
719
720 \layout {
721   \context {
722          % a little smaller so lyrics
723          % can be closer to the staff
724          \Staff
725           minimumVerticalExtent = #'(-3 . 3)
726   }
727 }
728
729 <<
730   \context ChoirStaff
731   <<
732     \context Lyrics = sopranos { s1 }
733     \context Staff = women <<
734       \context Voice =
735         sopranos { \voiceOne << \global \sopMusic >> }
736       \context Voice =
737         altos { \voiceTwo << \global \altoMusic >> }
738     >>
739     \context Lyrics = altos { s1 }
740     \context Lyrics = tenors { s1 }
741     \context Staff = men <<
742       \clef bass
743       \context Voice =
744         tenors { \voiceOne <<\global \tenorMusic >> }
745       \context Voice =
746         basses { \voiceTwo <<\global \bassMusic >> }
747     >>
748     \context Lyrics = basses { s1 }
749     \context Lyrics = sopranos \lyricsto sopranos \sopWords
750     \context Lyrics = altos \lyricsto altos \altoWords
751     \context Lyrics = tenors \lyricsto tenors \tenorWords
752     \context Lyrics = basses \lyricsto basses \bassWords
753   >>
754   \new PianoStaff
755   <<
756     \new Staff <<
757       \set Staff.printPartCombineTexts = ##f
758       \partcombine
759       << \global \sopMusic >>
760       << \global \altoMusic >>
761     >>
762     \new Staff <<
763       \clef bass
764       \set Staff.printPartCombineTexts = ##f
765       \partcombine
766       << \global \tenorMusic >>
767       << \global \bassMusic >>
768     >>
769   >>
770 >>
771 @end lilypond
772
773
774 @c bad node name to avoid node name confict
775 @node Ancient notation templates
776 @section Ancient notation templates
777
778 @subsection Transcription of mensural music
779
780 When transcribing mensural music, an incipit at the beginning of the
781 piece is useful to indicate the original key and tempo.  While today
782 musicians are used to bar lines in order to faster recognize rhythmic
783 patterns, bar lines where not yet invented during the period of
784 mensural music; in fact, the meter often changed after every few
785 notes.  As a compromise, bar lines are often printed between the
786 staves rather than on the staves.
787
788 @lilypond[quote,verbatim,linewidth=11.0\cm]
789 \version "2.4.0"
790
791 global = {
792   \set Score.skipBars = ##t
793
794   % incipit
795   \once \override Score.SystemStartBracket #'transparent = ##t
796   \override Score.SpacingSpanner #'spacing-increment = #1.0 % tight spacing
797   \key f \major
798   \time 2/2
799   \once \override Staff.TimeSignature #'style = #'neomensural
800   \override Voice.NoteHead #'style = #'neomensural
801   \override Voice.Rest #'style = #'neomensural
802   \set Staff.printKeyCancellation = ##f
803   \cadenzaOn % turn off bar lines
804   \skip 1*10
805   \once \override Staff.BarLine #'transparent = ##f
806   \bar "||"
807   \skip 1*1 % need this extra \skip such that clef change comes
808             % after bar line
809   \bar ""
810
811   % main
812   \revert Score.SpacingSpanner #'spacing-increment % CHECK: no effect?
813   \cadenzaOff % turn bar lines on again
814   \once \override Staff.Clef #'full-size-change = ##t
815   \set Staff.forceClef = ##t
816   \key g \major
817   \time 4/4
818   \override Voice.NoteHead #'style = #'default
819   \override Voice.Rest #'style = #'default
820
821   % FIXME: setting printKeyCancellation back to #t must not
822   % occur in the first bar after the incipit.  Dto. for forceClef.
823   % Therefore, we need an extra \skip.
824   \skip 1*1
825   \set Staff.printKeyCancellation = ##t
826   \set Staff.forceClef = ##f
827
828   \skip 1*7 % the actual music
829
830   % let finis bar go through all staves
831   \override Staff.BarLine #'transparent = ##f
832
833   % finis bar
834   \bar "|."
835 }
836
837 discantusNotes = {
838   \transpose c' c'' {
839     \set Staff.instrument = "Discantus  "
840
841     % incipit
842     \clef "neomensural-c1"
843     c'1. s2   % two bars
844     \skip 1*8 % eight bars
845     \skip 1*1 % one bar
846
847     % main
848     \clef "treble"
849     d'2. d'4 |
850     b e' d'2 |
851     c'4 e'4.( d'8 c' b |
852     a4) b a2 |
853     b4.( c'8 d'4) c'4 |
854     \once \override NoteHead #'transparent = ##t c'1 |
855     b\breve |
856   }
857 }
858
859 discantusLyrics = \lyricmode {
860   % incipit
861   IV-
862
863   % main
864   Ju -- bi -- |
865   la -- te De -- |
866   o, om --
867   nis ter -- |
868   ra, __ om- |
869   "..." |
870   -us. |
871 }
872
873 altusNotes = {
874   \transpose c' c'' {
875     \set Staff.instrument = "Altus  "
876
877     % incipit
878     \clef "neomensural-c3"
879     r1        % one bar
880     f1. s2    % two bars
881     \skip 1*7 % seven bars
882     \skip 1*1 % one bar
883
884     % main
885     \clef "treble"
886     r2 g2. e4 fis g | % two bars
887     a2 g4 e |
888     fis g4.( fis16 e fis4) |
889     g1 |
890     \once \override NoteHead #'transparent = ##t g1 |
891     g\breve |
892   }
893 }
894
895 altusLyrics = \lyricmode {
896   % incipit
897   IV-
898
899   % main
900   Ju -- bi -- la -- te | % two bars
901   De -- o, om -- |
902   nis ter -- ra, |
903   "..." |
904   -us. |
905 }
906
907 tenorNotes = {
908   \transpose c' c' {
909     \set Staff.instrument = "Tenor  "
910
911     % incipit
912     \clef "neomensural-c4"
913     r\longa   % four bars
914     r\breve   % two bars
915     r1        % one bar
916     c'1. s2   % two bars
917     \skip 1*1 % one bar
918     \skip 1*1 % one bar
919
920     % main
921     \clef "treble_8"
922     R1 |
923     R1 |
924     R1 |
925     r2 d'2. d'4 b e' | % two bars
926     \once \override NoteHead #'transparent = ##t e'1 |
927     d'\breve |
928   }
929 }
930
931 tenorLyrics = \lyricmode {
932   % incipit
933   IV-
934
935   % main
936   Ju -- bi -- la -- te | % two bars
937   "..." |
938   -us. |
939 }
940
941 bassusNotes = {
942   \transpose c' c' {
943     \set Staff.instrument = "Bassus  "
944
945     % incipit
946     \clef "bass"
947     r\maxima  % eight bars
948     f1. s2    % two bars
949     \skip 1*1 % one bar
950
951     % main
952     \clef "bass"
953     R1 |
954     R1 |
955     R1 |
956     R1 |
957     g2. e4 |
958     \once \override NoteHead #'transparent = ##t e1 |
959     g\breve |
960   }
961 }
962
963 bassusLyrics = \lyricmode {
964   % incipit
965   IV-
966
967   % main
968   Ju -- bi- |
969   "..." |
970   -us. |
971 }
972
973 \score {
974   \context StaffGroup = choirStaff <<
975     \context Voice =
976       discantusNotes << \global \discantusNotes >>
977     \context Lyrics =
978       discantusLyrics \lyricsto discantusNotes { \discantusLyrics }
979     \context Voice =
980       altusNotes << \global \altusNotes >>
981     \context Lyrics =
982       altusLyrics \lyricsto altusNotes { \altusLyrics }
983     \context Voice =
984       tenorNotes << \global \tenorNotes >>
985     \context Lyrics =
986       tenorLyrics \lyricsto tenorNotes { \tenorLyrics }
987     \context Voice =
988       bassusNotes << \global \bassusNotes >>
989     \context Lyrics =
990       bassusLyrics \lyricsto bassusNotes { \bassusLyrics }
991   >>
992   \layout {
993     \context {
994       \Score
995       \override BarLine #'transparent = ##t
996       \remove "System_start_delimiter_engraver"
997     }
998     \context {
999       \Voice
1000       \override Slur #'transparent = ##t
1001     }
1002   }
1003 }
1004 @end lilypond
1005
1006
1007
1008 @node Jazz combo
1009 @section Jazz combo
1010
1011 This is a much more complicated template, for a jazz ensemble.  Note that all
1012 instruments are notated in @code{\key c \major}.  This refers to the key in
1013 concert pitch; LilyPond will automatically transpose the key if the music
1014 is within a @code{\transpose} section.
1015
1016 @c TODO must clean up this jazz combo example
1017 @c   - transpositions stated in names (ie "trumpet in Bb" or whatever)
1018 @c   - one global section, instead of "global" (time) and "key"
1019 @c   - does it need those wierd macros?  sl, nsl, etc.
1020 @c   - maybe ask Amelie Zapf to clean it up, or whether I should just
1021 @c     make whatever changes I feel like.
1022
1023 @c FIXME: produces a warning ; key change merge.
1024 @c The `linewidth' argument is for the \header.
1025
1026 @lilypond[quote,verbatim,raggedright,linewidth]
1027 \version "2.4.0"
1028 \header {
1029   title = "Song"
1030   subtitle = "(tune)"
1031   composer = "Me"
1032   meter = "moderato"
1033   piece = "Swing"
1034   tagline = "LilyPond example file by Amelie Zapf,
1035              Berlin 07/07/2003"
1036   texidoc = "Jazz tune for combo
1037              (horns, guitar, piano, bass, drums)."
1038 }
1039
1040 #(set-global-staff-size 16)
1041 \include "english.ly"
1042
1043 %%%%%%%%%%%% Some macros %%%%%%%%%%%%%%%%%%%
1044
1045 sl = {
1046   \override NoteHead #'style = #'slash
1047   \override Stem #'transparent = ##t
1048 }
1049 nsl = {
1050   \revert NoteHead #'style
1051   \revert Stem #'transparent
1052 }
1053 cr = \override NoteHead #'style = #'cross
1054 ncr = \revert NoteHead #'style
1055
1056 %% insert chord name style stuff here.
1057
1058 jzchords = { }
1059
1060
1061 %%%%%%%%%%%% Keys'n'thangs %%%%%%%%%%%%%%%%%
1062
1063 global = {
1064   \time 4/4
1065 }
1066
1067 Key = { \key c \major }
1068
1069 % ############ Horns ############
1070
1071 % ------ Trumpet ------
1072 trpt = \transpose c d \relative c'' {
1073   \Key
1074   c1 c c
1075 }
1076 trpharmony = \transpose c' d {
1077   \jzchords
1078 }
1079 trumpet = {
1080   \global
1081   \set Staff.instrument = #"Trumpet"
1082   \clef treble
1083   \context Staff <<
1084     \trpt
1085   >>
1086 }
1087
1088 % ------ Alto Saxophone ------
1089 alto = \transpose c a \relative c' {
1090   \Key
1091   c1 c c
1092 }
1093 altoharmony = \transpose c' a {
1094   \jzchords
1095 }
1096 altosax = {
1097   \global
1098   \set Staff.instrument = #"Alto Sax"
1099   \clef treble
1100   \context Staff <<
1101     \alto
1102   >>
1103 }
1104
1105 % ------ Baritone Saxophone ------
1106 bari = \transpose c a' \relative c {
1107   \Key
1108   c1 c \sl d4^"Solo" d d d \nsl
1109 }
1110 bariharmony = \transpose c' a \chordmode {
1111   \jzchords s1 s d2:maj e:m7
1112 }
1113 barisax = {
1114   \global
1115   \set Staff.instrument = #"Bari Sax"
1116   \clef treble
1117   \context Staff <<
1118     \bari
1119   >>
1120 }
1121
1122 % ------ Trombone ------
1123 tbone = \relative c {
1124   \Key
1125   c1 c c
1126 }
1127 tboneharmony = \chordmode {
1128   \jzchords
1129 }
1130 trombone = {
1131   \global
1132   \set Staff.instrument = #"Trombone"
1133   \clef bass
1134   \context Staff <<
1135     \tbone
1136   >>
1137 }
1138
1139 % ############ Rhythm Section #############
1140
1141 % ------ Guitar ------
1142 gtr = \relative c'' {
1143   \Key
1144   c1 \sl b4 b b b \nsl c1
1145 }
1146 gtrharmony = \chordmode {
1147   \jzchords
1148   s1 c2:min7+ d2:maj9
1149 }
1150 guitar = {
1151   \global
1152   \set Staff.instrument = #"Guitar"
1153   \clef treble
1154   \context Staff <<
1155     \gtr
1156   >>
1157 }
1158
1159 %% ------ Piano ------
1160 rhUpper = \relative c'' {
1161   \voiceOne
1162   \Key
1163   c1 c c
1164 }
1165 rhLower = \relative c' {
1166   \voiceTwo
1167   \Key
1168   e1 e e
1169 }
1170
1171 lhUpper = \relative c' {
1172   \voiceOne
1173   \Key
1174   g1 g g
1175 }
1176 lhLower = \relative c {
1177   \voiceTwo
1178   \Key
1179   c1 c c
1180 }
1181
1182 PianoRH = {
1183   \clef treble
1184   \global
1185   \set Staff.midiInstrument = "acoustic grand"
1186   \context Staff <<
1187     \context Voice = one \rhUpper
1188     \context Voice = two \rhLower
1189   >>
1190 }
1191 PianoLH = {
1192   \clef bass
1193   \global
1194   \set Staff.midiInstrument = "acoustic grand"
1195   \context Staff <<
1196     \context Voice = one \lhUpper
1197     \context Voice = two \lhLower
1198   >>
1199 }
1200
1201 piano = {
1202   \context PianoStaff <<
1203     \set PianoStaff.instrument = #"Piano"
1204     \context Staff = upper \PianoRH
1205     \context Staff = lower \PianoLH
1206   >>
1207 }
1208
1209 % ------ Bass Guitar ------
1210 Bass = \relative c {
1211   \Key
1212   c1 c c
1213 }
1214 bass = {
1215   \global
1216   \set Staff.instrument = #"Bass"
1217   \clef bass
1218   \context Staff <<
1219     \Bass
1220   >>
1221 }
1222
1223 % ------ Drums ------
1224 up = \drummode {
1225   hh4 <hh sn>4 hh <hh sn> hh <hh sn>4
1226   hh4 <hh sn>4
1227   hh4 <hh sn>4
1228   hh4 <hh sn>4
1229 }
1230
1231 down = \drummode {
1232   bd4 s bd s bd s bd s bd s bd s
1233 }
1234
1235 drumContents = {
1236   \global
1237   <<
1238     \set DrumStaff.instrument = #"Drums"
1239     \new DrumVoice { \voiceOne \up }
1240     \new DrumVoice { \voiceTwo \down }
1241   >>
1242 }
1243
1244 %%%%%%%%% It All Goes Together Here %%%%%%%%%%%%%%%%%%%%%%
1245
1246 \score {
1247   <<
1248     \context StaffGroup = horns <<
1249       \context Staff = trumpet \trumpet
1250       \context Staff = altosax \altosax
1251       \context ChordNames = barichords \bariharmony
1252       \context Staff = barisax \barisax
1253       \context Staff = trombone \trombone
1254     >>
1255
1256     \context StaffGroup = rhythm <<
1257       \context ChordNames = chords \gtrharmony
1258       \context Staff = guitar \guitar
1259       \context PianoStaff = piano \piano
1260       \context Staff = bass \bass
1261       \new DrumStaff { \drumContents }
1262     >>
1263   >>
1264
1265   \layout {
1266     \context { \RemoveEmptyStaffContext }
1267     \context {
1268       \Score
1269       \override BarNumber #'padding = #3
1270       \override RehearsalMark #'padding = #2
1271       skipBars = ##t
1272     }
1273   }
1274
1275   \midi { \tempo 4 = 75 }
1276 }
1277 @end lilypond
1278
1279 @node Other templates
1280 @section Other templates
1281 @subsection All headers
1282
1283 This template displays all available headers.  Some of them are only
1284 used in the Mutopia project; they don't affect the printed output at
1285 all.  They are used if you want the piece to be listed with different
1286 information in the Mutopia database than you wish to have printed on the
1287 music.  For example, Mutopia lists the composer of the famous D major
1288 violin concerto as TchaikovskyPI, whereas perhaps you wish to print
1289 "Petr Tchaikowski" on your music.
1290
1291 @ The `linewidth' is for \header.
1292 @lilypond[quote,verbatim,raggedright,linewidth]
1293 \version "2.4.0"
1294 \header {
1295   dedication = "dedication"
1296   title = "Title"
1297   subtitle = "Subtitle"
1298   subsubtitle = "Subsubtitle"
1299   composer = "Composer (xxxx-yyyy)"
1300   opus = "Opus 0"
1301   piece = "Piece I"
1302   meter = "meter"
1303   instrument = "Instrument"
1304   arranger = "Arranger"
1305   poet = "Poet"
1306   texttranslator = "Translator"
1307   copyright = "public domain"
1308
1309   % These are headers used by the Mutopia Project
1310   % http://www.mutopiaproject.org/
1311   mutopiatitle = ""
1312   mutopiacomposer = ""
1313   mutopiapoet = ""
1314   mutopiainstrument = ""
1315   date = "composer's dates"
1316   source = "urtext "
1317   maintainer = "your name here"
1318   maintainerEmail = "your email here"
1319   maintainerWeb = "your home page"
1320   lastupdated = "2004/Aug/26"
1321 }
1322
1323 \score {
1324   \header {
1325     piece = "piece1"
1326     opus = "opus1"
1327   }
1328   { c'4 }
1329 }
1330
1331 \score {
1332   \header {
1333     piece = "piece2"
1334     opus = "opus2"
1335   }
1336   { c'4 }
1337 }
1338 @end lilypond
1339
1340 @subsection Gregorian template
1341
1342 This example demonstrates how to do modern transcriptions of Gregorian
1343 music.  Gregorian music has no measure, no stems; it uses only half and
1344 quarter notes, and two types of barlines, a short one indicating a rest,
1345 and a second one indicating a breath mark.
1346
1347 @lilypond[quote,verbatim,raggedright]
1348 barOne = { \once \override Staff.BarLine #'bar-size = #2
1349   \bar "|" }
1350 barTwo = { \once \override Staff.BarLine #'extra-offset = #'(0 . 2)
1351   \once \override Staff.BarLine #'bar-size = #2
1352   \bar "|" }
1353 chant = \relative c' {
1354   \set Score.timing = ##f
1355   \override Staff.Stem #'transparent = ##t
1356
1357   f4 a2 \barTwo
1358   g4 a2 f2 \barOne
1359   g4( f) f( g) a2
1360 }
1361 \score {
1362   \chant
1363   \layout{ }
1364   \midi { \tempo 4=60 }
1365 }
1366 @end lilypond
1367
1368 @subsection Bagpipe music
1369
1370 Here is an example of bagpipe music.  It demonstrates a big strength of
1371 LilyPond, compared to graphical score editors: in LilyPond, you can
1372 very easily reuse small segments of music without writing them out
1373 completely.  This template defines a large number of small segments
1374 (@code{taor}, @code{grip}, @code{thrd}, etc), which can be reused easily.
1375
1376 @c TODO - replace Bagpipe template with Andrew McNabb's work?
1377 @c  http://www.mcnabbs.org/andrew/linux/lilypond-ghb/
1378
1379 @lilypond[quote,verbatim]
1380 taor = { \grace { g32[ d' g e'] } }
1381 grip = { \grace { g32[ b g ]    } }
1382 thrd = { \grace { g32[ d' c']   } }
1383 birl = { \grace { g32[ a g]     } }
1384 gstd = { \grace { g'32[ d' g]   } }
1385 fgg  = { \grace { f32[ g'32]    } }
1386 dblb = { \grace { g'32[ b d']   } }
1387 dblc = { \grace { g'32[ c' d']  } }
1388 dble = { \grace { g'32[ e' f']  } }
1389 dblf = { \grace { g'32[ f' g']  } }
1390 dblg = { \grace { g'32[ f']     } }
1391 dbla = { \grace { a'32[ g']     } }
1392 lgg  = { \grace { g32  } }
1393 lag  = { \grace { a32  } }
1394 cg   = { \grace { c'32 } }
1395 eg   = { \grace { e'32 } }
1396 gg   = { \grace { g'32 } }
1397 dg   = { \grace { d'32 } }
1398 hag  = { \grace { a'32 } }
1399 gefg = { \grace { g'32[ e' f']  } }
1400 efg  = { \grace { e'32[ f']     } }
1401 gdcg = { \grace { g'32[ d' c']  } }
1402 gcdg = { \grace { g'32[ c' d']  } }
1403
1404 \transpose a a' {
1405   #(add-grace-property 'Voice 'Stem 'length 6)
1406   \time 6/8 \partial 4
1407   \tieUp
1408   \slurUp
1409
1410   f'4 |
1411   \gg f'4 e'8 \thrd d'4. |
1412   \eg a4.(a4) d'8 |
1413   \gg d'4 f'8 \dble e'4. ( | \noBreak
1414   e'8) d'4 \gg d'4 e'8 |
1415
1416   \break
1417   \time 9/8
1418   \dblf f'2.( f'4) d'8 |
1419   \time 6/8
1420   \dblg g'4 a'8 \gg a'4. |
1421   \thrd d'4.( d'4) \eg a8 |
1422   \time 9/8
1423   \dble e'4 \lag e'8 \gg e'16[ d'8. e'8] \gg f'4 g'8 |
1424
1425   \break
1426   \time 6/8
1427   \gg f'4 e'8 \thrd d'4. |
1428   \eg a4.( a4) d'8 |
1429   \dblg g'4 a'8 \gg a'4. |
1430   \thrd d'4.( d'4) f'8 |
1431
1432   \break
1433   \dblg g'4 e'8( e'8) \dblf f'8.[ e'16] |
1434   \thrd d'4.( d'4) \cg d'8 |
1435   \gg c'4 e'8 \thrd d'4.( |
1436   d'4.) \gdcg d'4.
1437 }
1438 @end lilypond
1439
1440
1441 @node Lilypond-book templates
1442 @section Lilypond-book templates
1443
1444 These templates are for use with @code{lilypond-book}.  If you're not familiar
1445 with this program, please refer to @ref{LilyPond-book}.
1446
1447 @subsection LaTeX
1448
1449 You can include LilyPond fragments in a LaTeX document.
1450
1451 @example
1452 \documentclass[]@{article@}
1453 \begin@{document@}
1454
1455 Normal LaTeX text.
1456
1457 \begin@{lilypond@}
1458 \relative c'' @{
1459 a4 b c d
1460 @}
1461 \end@{lilypond@}
1462
1463 More LaTeX text.
1464
1465 \begin@{lilypond@}
1466 \relative c'' @{
1467 d4 c b a
1468 @}
1469 \end@{lilypond@}
1470 \end@{document@}
1471 @end example
1472
1473 @subsection Texinfo
1474
1475 You can include LilyPond fragments in Texinfo; in fact, this entire manual
1476 is written in Texinfo.
1477
1478 @example
1479 \input texinfo
1480 @@node Top
1481
1482 Texinfo text
1483
1484 @@lilypond[verbatim,fragment,raggedright]
1485 a4 b c d
1486 @@end lilypond
1487
1488 More Texinfo text
1489
1490 @@lilypond[verbatim,fragment,raggedright]
1491 d4 c b a
1492 @@end lilypond
1493
1494 @@bye
1495 @end example