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