]> git.donarmstrong.com Git - lilypond.git/blob - ly/staff-tkit.ly
Web-fr: updates community
[lilypond.git] / ly / staff-tkit.ly
1 %\version "2.19.22"
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 (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 instrName name)
43                 "")
44          }
45          shortInstrumentName = \markup \smallCaps {
46            #(if show-instrName
47                 (cond
48                  (shortInstrName shortInstrName)
49                  (instrName (substring instrName 0 1))
50                  (else (substring name 0 1)))
51                 "")
52          }
53          midiInstrument = #(if midiName midiName "clarinet")
54          #(cond
55            (dynUp dynamicUp)
56            (dynDown dynamicDown)
57            (else dynamicNeutral))
58
59        }
60        {
61          #(if Key Key)
62          \clef #clef
63          \make-voice #name
64        }
65      #}
66      (make-music 'SequentialMusic 'void #t)))
67
68
69 make-two-voice-staff =
70 #(define-music-function (name clef v1name v2name)
71    (voice-prefix? string? voice-prefix? voice-prefix?)
72
73    "Make a vocal staff with two voices
74       name: the prefix to the staff name
75       clef: the clef to use
76     v1name: the prefix to the name of voice one
77     v2name: the prefix to the name of voice two "
78
79    (define v1music (make-id v1name "Music"))
80    (define v2music (make-id v2name "Music"))
81    (define instrName (make-id name "InstrumentName"))
82    (define v1InstrName (make-id v1name "InstrumentName"))
83    (define v2InstrName (make-id v2name "InstrumentName"))
84    (define shortInstrName (make-id name "ShortInstrumentName"))
85    (define v1ShortInstrName (make-id v1name "ShortInstrumentName"))
86    (define v2ShortInstrName (make-id v2name "ShortInstrumentName"))
87    (define v1midiName (make-id v1name "MidiInstrument"))
88    (define v2midiName (make-id v2name "MidiInstrument"))
89    (if (or v1music v2music)
90        #{
91          <<
92            \new Staff = #(string-append name "Staff")
93            \with {
94              \remove "Staff_performer"
95              instrumentName =
96                #(if instrName
97                  #{ \markup \smallCaps #instrName #}
98                  #{ \markup \right-column \smallCaps {
99                   #(if v1music
100                        (if v1InstrName v1InstrName v1name)
101                        "")
102                   #(if v2music
103                        (if v2InstrName v2InstrName v2name)
104                        "")
105                  } #} )
106              shortInstrumentName =
107                #(if shortInstrName
108                   #{ \markup \smallCaps #shortInstrName #}
109                   #{ \markup \right-column \smallCaps {
110                     #(if v1music
111                          (cond
112                           (v1ShortInstrName v1ShortInstrName)
113                           (v1InstrName (substring v1InstrName 0 1))
114                           (else (substring v1name 0 1)))
115                          "")
116                     #(if v2music
117                          (cond
118                           (v2ShortInstrName v2ShortInstrName)
119                           (v2InstrName (substring v2InstrName 0 1))
120                           (else (substring v2name 0 1)))
121                          "")
122                   } #} )
123            }
124            <<
125              #(if Key Key)
126              \clef #clef
127
128              #(if v1music
129                #{
130                  \new Voice = #(string-append v1name "Voice")
131                  \with {
132                    \consists "Staff_performer"
133                    \dynamicUp
134                    midiInstrument =
135                      #(if v1midiName v1midiName "clarinet")
136                  }
137                  <<
138                    #(if KeepAlive KeepAlive)
139                    #(if Time Time)
140                    #(if v2music voiceOne oneVoice)
141                    #v1music
142                  >>
143                #} )
144
145              #(if v2music
146                #{
147                  \new Voice = #(string-append v2name "Voice")
148                  \with {
149                    \consists "Staff_performer"
150                    \dynamicDown
151                    midiInstrument =
152                      #(if v2midiName v2midiName "clarinet")
153                  }
154                  <<
155                    #(if KeepAlive KeepAlive)
156                    #(if Time Time)
157                    #(if v1music voiceTwo oneVoice)
158                    #v2music
159                  >>
160                #} )
161            >>
162          >>
163        #}
164         (make-music 'SequentialMusic 'void #t)))