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