]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/examples.itely
more conversion for dash-change.
[lilypond.git] / Documentation / user / examples.itely
1 @c -*- coding: utf-8; 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,ragged-right]
31 \version "2.7.32"
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,ragged-right]
56 \version "2.7.32"
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,ragged-right]
87 \version "2.7.32"
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,ragged-right]
120 \version "2.7.32"
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,ragged-right]
161 \version "2.7.32"
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,ragged-right]
195 \version "2.7.32"
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,ragged-right]
251 \version "2.7.32"
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 { \context Voice = singer \upper }
275     \lyricsto "singer" \new Lyrics \text
276     \context Staff = lower {
277       \clef bass
278       \lower
279     }
280   >>
281   \layout {
282     \context { \GrandStaff \accepts "Lyrics" }
283     \context { \Lyrics \consists "Bar_engraver" }
284   }
285   \midi { \tempo 4=60 }
286 }
287 @end lilypond
288
289
290 @subsection Piano centered dynamics
291
292 Many piano scores have the dynamics centered between the two
293 staffs.  This requires a bit of tweaking to implement, but
294 since the template is right here, you don't have to do the
295 tweaking yourself.
296
297 @lilypond[quote,verbatim,ragged-right]
298 \version "2.7.32"
299 upper = \relative c'' {
300   \clef treble
301   \key c \major
302   \time 4/4
303
304   a b c d
305 }
306
307 lower = \relative c {
308   \clef bass
309   \key c \major
310   \time 4/4
311
312   a2 c
313 }
314
315 dynamics = {
316   s2\fff\> s4
317   s\!\pp
318 }
319
320 pedal = {
321   s2\sustainDown s2\sustainUp
322 }
323
324 \score {
325   \context PianoStaff <<
326     \context Staff=upper \upper
327     \context Dynamics=dynamics \dynamics
328     \context Staff=lower <<
329       \clef bass
330       \lower
331     >>
332     \context Dynamics=pedal \pedal
333   >>
334   \layout {
335     \context {
336       \type "Engraver_group"
337       \name Dynamics
338       \alias Voice % So that \cresc works, for example.
339       \consists "Output_property_engraver"
340
341       \override VerticalAxisGroup #'minimum-Y-extent = #'(-1 . 1)
342       pedalSustainStrings = #'("Ped." "*Ped." "*")
343       pedalUnaCordaStrings = #'("una corda" "" "tre corde")
344
345       \consists "Piano_pedal_engraver"
346       \consists "Script_engraver"
347       \consists "Dynamic_engraver"
348       \consists "Text_engraver"
349
350       \override TextScript #'font-size = #2
351       \override TextScript #'font-shape = #'italic
352       \override DynamicText #'extra-offset = #'(0 . 2.5)
353       \override Hairpin #'extra-offset = #'(0 . 2.5)
354
355       \consists "Skip_event_swallow_translator"
356
357       \consists "Axis_group_engraver"
358     }
359     \context {
360       \PianoStaff
361       \accepts Dynamics
362       \override VerticalAlignment #'forced-distance = #7
363     }
364   }
365 }
366 \score {
367   \context PianoStaff <<
368     \context Staff=upper << \upper \dynamics >>
369     \context Staff=lower << \lower \dynamics >>
370     \context Dynamics=pedal \pedal
371   >>
372   \midi {
373     \context {
374       \type "Performer_group"
375       \name Dynamics
376       \consists "Piano_pedal_performer"
377     }
378     \context {
379       \PianoStaff
380       \accepts Dynamics
381     }
382   }
383 }
384 @end lilypond
385
386
387 @node String quartet
388 @section String quartet
389 @subsection String quartet
390
391 This template demonstrates a string quartet.  It also uses a @code{\global}
392 section for time and key signatures.
393
394 @lilypond[quote,verbatim,ragged-right]
395 \version "2.7.32"
396
397 global= {
398   \time 4/4
399   \key c \major
400 }
401
402 violinOne = \new Voice { \relative c''{
403   \set Staff.instrument = "Violin 1 "
404
405   c2 d e1
406
407 \bar "|." }}
408 violinTwo = \new Voice { \relative c''{
409   \set Staff.instrument = "Violin 2 "
410
411   g2 f e1
412
413 \bar "|." }}
414 viola = \new Voice { \relative c' {
415   \set Staff.instrument = "Viola "
416   \clef alto
417
418   e2 d c1
419
420 \bar "|." }}
421 cello = \new Voice { \relative c' {
422   \set Staff.instrument = "Cello     "
423   \clef bass
424
425   c2 b a1
426
427 \bar "|."}}
428
429 \score {
430    \new StaffGroup <<
431       \new Staff << \global \violinOne >>
432       \new Staff << \global \violinTwo >>
433       \new Staff << \global \viola >>
434       \new Staff << \global \cello >>
435    >>
436    \layout { }
437    \midi { \tempo 4=60}
438 }
439 @end lilypond
440
441 @subsection String quartet parts
442
443 The previous example produces a nice string quartet, but what if you
444 needed to print parts?  This template demonstrates how to use the
445 @code{\tag} feature to easily split a piece into individual parts.
446
447 You need to split this template into separate files; the filenames
448 are contained in comments at the beginning of each file.  @code{piece.ly}
449 contains all the music definitions.  The other files -- @code{score.ly},
450 @code{vn1.ly}, @code{vn2.ly}, @code{vla.ly}, and
451 @code{vlc.ly} -- produce the appropiate part.
452
453 @verbatim
454 %%%%% piece.ly
455 \version "2.7.32"
456
457 global= {
458   \time 4/4
459   \key c \major
460 }
461
462 Violinone = \new Voice { \relative c''{
463   \set Staff.instrument = "Violin 1 "
464
465   c2 d e1
466
467 \bar "|." }}   %*********************************
468 Violintwo = \new Voice { \relative c''{
469   \set Staff.instrument = "Violin 2 "
470
471   g2 f e1
472
473 \bar "|." }}   %*********************************
474 Viola = \new Voice { \relative c' {
475   \set Staff.instrument = "Viola "
476   \clef alto
477
478   e2 d c1
479
480 \bar "|." }}   %*********************************
481 Cello = \new Voice { \relative c' {
482   \set Staff.instrument = "Cello     "
483   \clef bass
484
485   c2 b a1
486
487 \bar "|."}}   %**********************************
488
489 music = {
490   <<
491     \tag #'(score vn1) \new Staff { << \global \Violinone >> }
492     \tag #'(score vn2) \new Staff { << \global \Violintwo>> }
493     \tag #'(score vla) \new Staff { << \global \Viola>> }
494     \tag #'(score vlc) \new Staff { << \global \Cello>> }
495   >>
496 }
497
498
499
500 %%%%% score.ly
501 \version "2.7.32"
502 \include "piece.ly"
503 #(set-global-staff-size 14)
504 \score {
505   \new StaffGroup \keepWithTag #'score \music
506   \layout { }
507   \midi { \tempo 4 = 60 }
508 }
509
510
511 %%%%% vn1.ly
512 \version "2.7.32"
513 \include "piece.ly"
514 \score { 
515   \keepWithTag #'vn1 \music
516   \layout { }
517 }
518
519
520 %%%%% vn2.ly
521 \version "2.7.32"
522 \include "piece.ly"
523 \score { 
524   \keepWithTag #'vn2 \music
525   \layout { }
526 }
527
528
529 %%%%% vla.ly
530 \version "2.7.32"
531 \include "piece.ly"
532 \score { 
533   \keepWithTag #'vla \music
534   \layout { }
535 }
536
537
538 %%%%% vlc.ly
539 \version "2.7.32"
540 \include "piece.ly"
541 \score { 
542   \keepWithTag #'vlc \music
543   \layout { }
544 }
545 @end verbatim
546
547
548 @node Vocal ensembles
549 @section Vocal ensembles
550
551 @subsection SATB vocal score
552
553 Here is a standard four-part SATB vocal score.  With larger ensembles,
554 it's often useful to include a section which is included in all
555 parts.  For example, the time signature and key signatures are almost
556 always the same for all parts.
557
558 @lilypond[quote,verbatim,ragged-right]
559 \version "2.7.32"
560 global = {
561    \key c \major
562    \time 4/4
563 }
564
565 sopMusic = \relative c'' {
566    c4 c c8[( b)] c4
567 }
568 sopWords = \lyricmode {
569    hi hi hi hi
570 }
571
572 altoMusic = \relative c' {
573    e4 f d e
574 }
575 altoWords =\lyricmode {
576    ha ha ha ha
577 }
578
579 tenorMusic = \relative c' {
580    g4 a f g
581 }
582 tenorWords = \lyricmode {
583    hu hu hu hu
584 }
585
586 bassMusic = \relative c {
587    c4 c g c
588 }
589 bassWords = \lyricmode {
590    ho ho ho ho
591 }
592
593 \score {
594    \context ChoirStaff <<
595       \context Lyrics = sopranos { s1 }
596       \context Staff = women <<
597          \context Voice =
598            sopranos { \voiceOne << \global \sopMusic >> }
599          \context Voice =
600            altos { \voiceTwo << \global \altoMusic >> }
601       >>
602       \context Lyrics = altos { s1 }
603       \context Lyrics = tenors { s1 }
604       \context Staff = men <<
605          \clef bass
606          \context Voice =
607            tenors { \voiceOne <<\global \tenorMusic >> }
608          \context Voice =
609            basses { \voiceTwo <<\global \bassMusic >> }
610       >>
611       \context Lyrics = basses { s1 }
612       \context Lyrics = sopranos \lyricsto sopranos \sopWords
613       \context Lyrics = altos \lyricsto altos \altoWords
614       \context Lyrics = tenors \lyricsto tenors \tenorWords
615       \context Lyrics = basses \lyricsto basses \bassWords
616    >>
617
618    \layout {
619       \context {
620          % a little smaller so lyrics
621          % can be closer to the staff
622          \Staff
623          \override VerticalAxisGroup #'minimum-Y-extent = #'(-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,ragged-right]
639 \version "2.7.32"
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           \override VerticalAxisGroup #'minimum-Y-extent = #'(-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 were 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,line-width=11.0\cm]
741 \version "2.7.32"
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 `line-width' argument is for the \header.
977
978 @lilypond[quote,verbatim,ragged-right,line-width]
979 \version "2.7.32"
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 `line-width' is for \header.
1244 @lilypond[quote,verbatim,ragged-right,line-width]
1245 \version "2.7.32"
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   { c'4 }
1277   \header {
1278     piece = "piece1"
1279     opus = "opus1"
1280   }
1281 }
1282
1283 \score {
1284   { c'4 }
1285   \header {
1286     piece = "piece2"
1287     opus = "opus2"
1288   }
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,ragged-right]
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
1321 @node Lilypond-book templates
1322 @section Lilypond-book templates
1323
1324 These templates are for use with @code{lilypond-book}.  If you're not familiar
1325 with this program, please refer to @ref{LilyPond-book}.
1326
1327 @subsection LaTeX
1328
1329 You can include LilyPond fragments in a LaTeX document.
1330
1331 @example
1332 \documentclass[]@{article@}
1333
1334 \begin@{document@}
1335
1336 Normal LaTeX text.
1337
1338 \begin@{lilypond@}
1339 \relative c'' @{
1340 a4 b c d
1341 @}
1342 \end@{lilypond@}
1343
1344 More LaTeX text.
1345
1346 \begin@{lilypond@}
1347 \relative c'' @{
1348 d4 c b a
1349 @}
1350 \end@{lilypond@}
1351 \end@{document@}
1352 @end example
1353
1354 @subsection Texinfo
1355
1356 You can include LilyPond fragments in Texinfo; in fact, this entire manual
1357 is written in Texinfo.
1358
1359 @example
1360 \input texinfo
1361 @@node Top
1362
1363 Texinfo text
1364
1365 @@lilypond[verbatim,fragment,ragged-right]
1366 a4 b c d
1367 @@end lilypond
1368
1369 More Texinfo text
1370
1371 @@lilypond[verbatim,fragment,ragged-right]
1372 d4 c b a
1373 @@end lilypond
1374
1375 @@bye
1376 @end example