]> git.donarmstrong.com Git - lilypond.git/blob - ly/satb.ly
Issue 3720: Add SATB built-in template
[lilypond.git] / ly / satb.ly
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 %%                                                %%
3 %%     Accompanied Choir with Multiple Verses     %%
4 %%                                                %%
5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6
7 %{
8   This file may be \include'd in a score to provide the
9   context structure for a score arrangement consisting
10   of the following staves:
11
12   Descant Staff
13   Soprano and Alto (optionally on two Staves or one Staff)
14   Multiple verses (up to 9)
15   Tenor and Bass (optionally on two Staves or one Staff)
16   Piano Staff
17
18   It is intended primarily to hide the complexity of the context
19   structure from newcomers to LilyPond, but is also useful as a
20   shorthand for seasoned users.
21
22   Usage:
23
24   satb.ly should be included at the *end* of the input file. Before
25   it are placed the required music and lyrics by redefining specific
26   variables, like this:
27
28   \paper { ... }
29   \header { ... }
30   Key = { ... }
31   Time = { ... }
32   DescantMusic = \relative { ... }
33   DescantLyrics = \lyricmode { ... }
34   SopranoMusic = \relative { ... }
35   SopranoLyrics = \lyricmode { ... }
36   AltoMusic = \relative { ... }
37   AltoLyrics = \lyricmode { ... }
38   VerseOne = \lyricmode { ... }
39   VerseTwo = \lyricmode { ... }
40   ...
41   VerseNine = \lyricmode { ... }
42   TenorMusic = \relative { ... }
43   TenorLyrics = \lyricmode { ... }
44   BassMusic = \relative { ... }
45   BassLyrics = \lyricmode { ... }
46   PianoRHMusic = \relative { ... }
47   PianoDynamics = { ... }
48   PianoLHMusic = \relative { ... }
49   TwoVoicesPerStaff = ##f
50   \include "satb.ly"
51
52   All of the definitions are optional. Staves with no music will be
53   omitted from the output.
54
55   Other variables, such as the instrumentName, can also be changed by
56   defining variables like AltoInstrumentName.  The key is defined in
57   the variable Key, and the structure of time and repeats in the
58   variable Time, using spacer rests.  A \layout block may be defined in
59   the variable Layout.  There is no default \header block and no default
60   \paper block.
61
62   Music may be tagged with #'print or #'play to be included only in
63   the printed score or in the MIDI file respectively.
64
65 %}
66
67 #(defmacro defaulting (name . default)
68   (if (defined? name) name (if (pair? default) (car default) '#{#})))
69
70 #(define (sym . strings) (string->symbol (apply string-append strings)))
71
72 #(defmacro short-name (part)
73   "Use PartShortInstrumentName, or the first letter of
74 PartInstrumentName or its default."
75   (if (defined? (sym part "Music"))
76     (let ((sname (sym part "ShortInstrumentName")))
77       (if (defined? sname)
78         sname
79         `(substring (defaulting ,(sym part "InstrumentName") ,part)
80                     0 1)))
81     ""))
82
83 #(defmacro lyrics-if-defined (name voice . optionals)
84   (let ((above (if (pair? optionals) (car optionals) #f)))
85     (if (defined? name)
86       `(make-music 'ContextSpeccedMusic
87          'create-new #t
88          'context-type 'Lyrics
89          'property-operations ',(if above `((assign alignAboveContext ,above)) '())
90          'element (make-music 'LyricCombineMusic
91                    'associated-context ,voice
92                    'element ,name))
93       #{#})))
94
95 #(defmacro one-voice-staff (name clef)
96   `#{ <<
97      \new Staff = #(identity ,name) \with {
98        instrumentName = \markup \smallCaps
99          #(defaulting ,(sym name "InstrumentName") ,name)
100        shortInstrumentName = \markup \smallCaps #(short-name ,name)
101        midiInstrument = "clarinet"
102      } {
103        #(defaulting Key)
104        \clef #(identity ,clef)
105        \new Voice = #(identity ,name) <<
106          #(defaulting Time)
107          \dynamicUp
108          #(defaulting ,(sym name "Music"))
109        >>
110      }
111      #(lyrics-if-defined ,(sym name "Lyrics") ,name)
112      #(lyrics-if-defined ,(sym name "LyricsOne") ,name)
113      #(lyrics-if-defined ,(sym name "LyricsTwo") ,name)
114      #(lyrics-if-defined ,(sym name "LyricsThree") ,name)
115    >> #})
116
117 #(defmacro two-voice-staff (name clef v1name v2name)
118   `#{ <<
119     \new Staff = #(identity ,name) \with {
120       instrumentName = \markup \right-column \smallCaps {
121         #(defaulting ,(sym v1name "InstrumentName") ,v1name)
122         #(defaulting ,(sym v2name "InstrumentName") ,v2name)
123       }
124       shortInstrumentName = \markup \right-column \smallCaps {
125         #(short-name ,v1name)
126         #(short-name ,v2name)
127       }
128       midiInstrument = "clarinet"
129     } <<
130       #(defaulting Key)
131       \clef #(identity ,clef)
132       \new Voice = #(identity ,v1name) <<
133         #(defaulting Time)
134         \voiceOne
135         \dynamicUp
136         #(defaulting ,(sym v1name "Music"))
137       >>
138       \new Voice = #(identity ,v2name) <<
139         #(defaulting Time)
140         \voiceTwo
141         #(defaulting ,(sym v2name "Music"))
142       >>
143     >>
144     #(lyrics-if-defined ,(sym v1name "Lyrics") ,v1name ,name)
145     #(lyrics-if-defined ,(sym v1name "LyricsOne") ,v1name ,name)
146     #(lyrics-if-defined ,(sym v1name "LyricsTwo") ,v1name ,name)
147     #(lyrics-if-defined ,(sym v1name "LyricsThree") ,v1name ,name)
148     #(lyrics-if-defined ,(sym v2name "Lyrics") ,v2name)
149     #(lyrics-if-defined ,(sym v2name "LyricsOne") ,v2name)
150     #(lyrics-if-defined ,(sym v2name "LyricsTwo") ,v2name)
151     #(lyrics-if-defined ,(sym v2name "LyricsThree") ,v2name)
152   >> #})
153
154 SATB = <<
155   \new ChoirStaff
156   \with {
157     \override VerticalAxisGroup.remove-empty = ##t
158     \override VerticalAxisGroup.remove-first = ##t
159   }
160   <<
161     #(one-voice-staff "Descant" "treble")
162
163     #(if (defaulting TwoVoicesPerStaff #f)
164       (two-voice-staff "Women" "treble" "Soprano" "Alto")
165       (make-simultaneous-music (list (one-voice-staff "Soprano" "treble")
166                                      (one-voice-staff "Alto" "treble"))))
167
168     #(lyrics-if-defined VerseOne "Soprano")
169     #(lyrics-if-defined VerseTwo "Soprano")
170     #(lyrics-if-defined VerseThree "Soprano")
171     #(lyrics-if-defined VerseFour "Soprano")
172     #(lyrics-if-defined VerseFive "Soprano")
173     #(lyrics-if-defined VerseSix "Soprano")
174     #(lyrics-if-defined VerseSeven "Soprano")
175     #(lyrics-if-defined VerseEight "Soprano")
176     #(lyrics-if-defined VerseNine "Soprano")
177
178     #(if (defaulting TwoVoicesPerStaff #f)
179       (two-voice-staff "Men" "bass" "Tenor" "Bass")
180       (make-simultaneous-music (list (one-voice-staff "Tenor" "treble_8")
181                                      (one-voice-staff "Bass" "bass"))))
182   >>  % End ChoirStaff
183
184   \new PianoStaff
185   \with {
186     instrumentName = \markup \smallCaps
187                        #(defaulting PianoInstrumentName "Piano" )
188     shortInstrumentName = \markup \smallCaps #(short-name "Piano" )
189     \override VerticalAxisGroup.remove-empty = ##t
190     \override VerticalAxisGroup.remove-first = ##t
191   }
192   <<
193     \new Staff {
194       \clef "treble"
195       #(defaulting Key)
196       \new Voice <<
197         #(defaulting Time)
198         #(defaulting PianoRHMusic)
199       >>
200     }
201     \new Dynamics {
202       #(defaulting PianoDynamics)
203     }
204     \new Staff {
205       \clef "bass"
206       #(defaulting Key)
207       \new Voice <<
208         #(defaulting Time)
209         #(defaulting PianoLHMusic)
210       >>
211     }
212   >>
213 >>
214
215 \score {
216   \keepWithTag #'print \SATB
217   \layout { #(defaulting Layout) }
218 }
219
220 \score {
221   \keepWithTag #'play \SATB
222   \midi { }
223 }
224