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