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