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