3 %%% These are the general utility functions and storage
4 % used by the built-in templates and the template kits
5 % (tkits) supporting them.
7 % TODO: these may be more sensibly (re)defined as a scm file
10 "Return the identifier with the value str"
11 (ly:parser-lookup (string->symbol str)))
13 #(define (make-id a b)
14 "Return the identifier formed from concatenating the
15 two strings provided as arguments."
16 (get-id (string-append a b)))
18 #(define (cartesian a b)
19 "Return a list formed from concatenating every element
20 of list a with every element of list b (the cartesian
30 #(define (define-missing-variables! ids)
31 "Check if each of the identifiers listed in the argument is
32 known to the parser. If any are not, define them and set
36 (define sym (string->symbol id))
37 (if (null? (ly:parser-lookup sym))
38 (ly:parser-define! sym #f)))
41 % Define the lists used to hold the names and
42 % component names which form the variable names
43 % used in the templates. These are populated by the
44 % set-music-definitions! procedure
45 % The variables defined here as empty lists will be provided
46 % by the template, and may be set to any values there.
47 #(define voice-prefixes '()) % eg "Soprano"
48 #(define all-music-names '()) % eg "SopranoMusic"
49 #(define lyrics-postfixes '()) % eg "Lyrics"
50 #(define lyrics-names '()) % eg "VerseOne"
52 % Define the derived variables to be populated
53 #(define all-music-lyrics-names '()) % eg "SopranoLyrics"
54 #(define AllMusic (make-music 'SequentialMusic 'void #t))
55 #(define KeepAlive AllMusic) % used to ensure voices don't terminate
56 #(define have-music #f) % -> #t when at least one music name
58 #(define voice-postfixes
59 ;; These names are used verbatim in code, so may not be changed
63 "ShortInstrumentName"))
65 #(define variable-names
66 ;; These names are used verbatim in code, so may not be changed
73 % Define the predicates used in the tkits and templates
74 #(define (above-or-below? x)
75 (member x '("Above" "Below")))
77 #(define (up-or-down? x)
78 (member x '("Down" "Up" "")))
80 #(define (voice-prefix? x)
81 (member x voice-prefixes))
83 #(define (vocal-lyrics-or-verses? x)
84 (or (member x lyrics-postfixes)
85 (member x lyrics-names)))
88 #(define (set-music-definitions! prefixes lyr-postfixes lyr-names)
89 "Populate the name definitions and their derivatives
90 with the values provided by the calling template"
91 (set! voice-prefixes prefixes)
92 (append! variable-names lyr-names)
94 (cartesian voice-prefixes '("Music")))
95 (set! lyrics-postfixes lyr-postfixes)
96 (set! lyrics-names lyr-names)
97 (set! all-music-lyrics-names
98 (cartesian voice-prefixes (append
101 (define-missing-variables! (append
102 all-music-lyrics-names
105 (make-simultaneous-music
112 (skip-of-length AllMusic))
116 (ly:music-length KeepAlive))))