]> git.donarmstrong.com Git - lilypond.git/blob - ly/staff-tkit.ly
Issue 3799: New satb.ly built-in template and template framework
[lilypond.git] / ly / staff-tkit.ly
1 %\version "2.19.19"
2
3 \include "voice-tkit.ly"
4
5
6 %% Staff-oriented functions
7
8 % These assume the following lists have been defined:
9 %   voice-prefixes  eg "Soprano"
10 %   voice-postfixes  eg "Music"
11 %   lyrics-postfixes  eg "Lyrics"
12 %   lyrics-names  eg "VerseOne"
13 %   variable-names  eg "Time"
14 %
15 % The first three lists are used to generate compound
16 % names such as "SopranoLyrics" and "SopranoInstrumentName"
17 % The last two lists of names are used as-is.
18
19
20 make-one-voice-staff =
21 #(define-music-function (parser location show-instrName name clef dynamic-direction)
22    ((boolean? #t) voice-prefix? string? (up-or-down? ""))
23
24    "Make a staff with one voice (no lyrics)
25     show-instrName: show instrument and short instrument names?
26               name: the default prefix for instrument name and music
27               clef: the clef for this staff
28  dynamic-direction: dynamics are up, down or neither"
29
30    (define music (make-id name "Music"))
31    (define instrName (make-id name "InstrumentName"))
32    (define shortInstrName (make-id name "ShortInstrumentName"))
33    (define midiName (make-id name "MidiInstrument"))
34    (define dynUp (equal? dynamic-direction "Up"))
35    (define dynDown (equal? dynamic-direction "Down"))
36    (if music
37      #{
38        \new Staff = #(string-append name "Staff")
39        \with {
40          instrumentName = \markup \smallCaps {
41            #(if show-instrName
42                 (if instrName
43                      #{ #instrName #}
44                      #{ #name #} )
45                 #{ "" #} )
46          }
47          shortInstrumentName = \markup \smallCaps {
48            #(if show-instrName
49                 (if shortInstrName
50                      #{ #shortInstrName #}
51                      (if instrName
52                          #{ #(substring instrName 0 1) #}
53                          #{ #(substring name 0 1) #} ))
54                      #{ "" #} )
55          }
56          midiInstrument =
57            #(if midiName
58                 #{ #midiName #}
59                 #{ "clarinet" #} )
60          #(if dynUp
61               #{ \dynamicUp #}
62               (if dynDown
63                   #{ \dynamicDown #}
64                   #{ \dynamicNeutral #} ))
65        }
66        {
67          #(if Key #{ \Key #} )
68          \clef #clef
69          \make-voice #name
70        }
71      #}
72      (make-music 'SequentialMusic 'void #t)))
73
74
75 make-two-voice-staff =
76 #(define-music-function (parser location name clef v1name v2name)
77    (voice-prefix? string? voice-prefix? voice-prefix?)
78
79    "Make a vocal staff with two voices
80       name: the prefix to the staff name
81       clef: the clef to use
82     v1name: the prefix to the name of voice one
83     v2name: the prefix to the name of voice two "
84
85    (define v1music (make-id v1name "Music"))
86    (define v2music (make-id v2name "Music"))
87    (define instrName (make-id name "InstrumentName"))
88    (define v1InstrName (make-id v1name "InstrumentName"))
89    (define v2InstrName (make-id v2name "InstrumentName"))
90    (define shortInstrName (make-id name "ShortInstrumentName"))
91    (define v1ShortInstrName (make-id v1name "ShortInstrumentName"))
92    (define v2ShortInstrName (make-id v2name "ShortInstrumentName"))
93    (define v1midiName (make-id v1name "MidiInstrument"))
94    (define v2midiName (make-id v2name "MidiInstrument"))
95    (if (or v1music v2music)
96        #{
97          <<
98            \new Staff = #(string-append name "Staff")
99            \with {
100              \remove "Staff_performer"
101              instrumentName =
102                #(if instrName
103                  #{ \markup \smallCaps #instrName #}
104                  #{ \markup \right-column \smallCaps {
105                   #(if v1music
106                        (if v1InstrName
107                            v1InstrName
108                            v1name)
109                        "")
110                   #(if v2music
111                        (if v2InstrName
112                            v2InstrName
113                            v2name)
114                        "") } #} )
115              shortInstrumentName =
116                #(if shortInstrName
117                   #{ \markup \smallCaps #shortInstrName #}
118                   #{ \markup \right-column \smallCaps {
119                     #(if v1music
120                          (if v1ShortInstrName
121                              v1ShortInstrName
122                              (if v1InstrName
123                                  (substring v1InstrName 0 1)
124                                  (substring v1name 0 1)))
125                          "")
126                     #(if v2music
127                          (if v2ShortInstrName
128                              v2ShortInstrName
129                              (if v2InstrName
130                                  (substring v2InstrName 0 1)
131                                  (substring v2name 0 1)))
132                          "") } #} )
133            }
134            <<
135              #(if Key #{ \Key #} )
136              \clef #clef
137
138              #(if v1music
139                #{
140                  \new Voice = #(string-append v1name "Voice")
141                  \with {
142                    \consists "Staff_performer"
143                    \dynamicUp
144                    midiInstrument =
145                      #(if v1midiName
146                           #{ #v1midiName #}
147                           #{ "clarinet" #})
148                  }
149                  <<
150                    #(if KeepAlive #{ \KeepAlive #} )
151                    #(if Time #{ \Time #} )
152                    #(if v2music #{ \voiceOne #} #{ \oneVoice #} )
153                    #v1music
154                  >>
155                #} )
156
157              #(if v2music
158                #{
159                  \new Voice = #(string-append v2name "Voice")
160                  \with {
161                    \consists "Staff_performer"
162                    \dynamicDown
163                    midiInstrument =
164                      #(if v2midiName
165                           #{ #v2midiName #}
166                           #{ "clarinet" #})
167                  }
168                  <<
169                    #(if KeepAlive #{ \KeepAlive #} )
170                    #(if Time #{ \Time #} )
171                    #(if v1music #{ \voiceTwo #} #{ \oneVoice #} )
172                    #v2music
173                  >>
174                #} )
175            >>
176          >>
177        #}
178         (make-music 'SequentialMusic 'void #t)))