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