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