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