summaryrefslogtreecommitdiff
path: root/ly/lyrics-tkit.ly
blob: 0f6a0a7febb010b5efb6a778d9194495d63fb9c2 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
%\version "2.19.22"

%%% The function used by the built-in templates to
%   build a lyrics context and associate it with a voice.

\include "voice-tkit.ly"

make-one-stanza =
#(define-music-function
  (pos staffPrefix voicePrefix altVoicePrefix lyrics)
  ((above-or-below? #f)
   voice-prefix?
   voice-prefix?
   (voice-prefix?)
   vocal-lyrics-or-verses?)

   "Make a single stanza
           (pos: positioned Above or Below the named staff)
    staffPrefix: voice prefix for the staff to be positioned against
    voicePrefix: voice prefix for the associated voice
(altVoicePrefix: voice prefix for the associated voice
                 if the first is not present)
         lyrics: the words"

   (let* ((lyrics-name (string-append voicePrefix lyrics))
          (staff-name (string-append staffPrefix "Staff"))
          (music-name (make-id voicePrefix "Music"))
          (assoc-voice-name (if music-name
                               voicePrefix
                               altVoicePrefix))
          (with-clause
           (if pos
               #{ \with {
                    #(string-append "align" pos "Context") = #staff-name
                  }
               #}
               (make-music 'SequentialMusic 'void #t)))
          (stanza (if (member lyrics lyrics-postfixes)
                        (make-id voicePrefix lyrics)
                        (get-id lyrics))))
   (if (and stanza  ;we need lyrics and at least one associated voice
            (or music-name
                (make-id altVoicePrefix "Music")))
        #{
          \new Lyrics = #lyrics-name
          \with { #with-clause }
          \lyricsto #(string-append assoc-voice-name "Voice")
          { #stanza }
        #}
        (make-music 'SequentialMusic 'void #t))))