2 ;; (name . (glyph clef-position octavation))
4 ;; -- the name clefOctavation is misleading. The value 7 is 1 octave, not 7 Octaves.
6 (define supported-clefs '(
7 ("treble" . ("clefs-G" -2 0))
8 ("violin" . ("clefs-G" -2 0))
9 ("G" . ("clefs-G" -2 0))
10 ("G2" . ("clefs-G" -2 0))
11 ("french" . ("clefs-G" -4 0))
12 ("soprano" . ("clefs-C" -4 0))
13 ("mezzosoprano" . ("clefs-C" -2 0))
14 ("alto" . ("clefs-C" 0 0))
15 ("C" . ("clefs-C" 0 0))
16 ("tenor" . ("clefs-C" 2 0))
17 ("baritone" . ("clefs-C" 4 0))
18 ("varbaritone" . ("clefs-F" 0 0))
19 ("bass" . ("clefs-F" 2 0))
20 ("F" . ( "clefs-F" 2 0))
21 ("subbass" . ("clefs-F" 4 0))
22 ("percussion" . ("clefs-percussion" 0 0))
23 ("tab" . ("clefs-tab" 0 0))
25 ;; should move mensural stuff to separate file?
26 ("vaticana_do1" . ("clefs-vaticana_do" -1 0))
27 ("vaticana_do2" . ("clefs-vaticana_do" 1 0))
28 ("vaticana_do3" . ("clefs-vaticana_do" 3 0))
29 ("vaticana_fa1" . ("clefs-vaticana_fa" -1 0))
30 ("vaticana_fa2" . ("clefs-vaticana_fa" 1 0))
31 ("medicaea_do1" . ("clefs-medicaea_do" -1 0))
32 ("medicaea_do2" . ("clefs-medicaea_do" 1 0))
33 ("medicaea_do3" . ("clefs-medicaea_do" 3 0))
34 ("medicaea_fa1" . ("clefs-medicaea_fa" -1 0))
35 ("medicaea_fa2" . ("clefs-medicaea_fa" 1 0))
36 ("hufnagel_do1" . ("clefs-hufnagel_do" -1 0))
37 ("hufnagel_do2" . ("clefs-hufnagel_do" 1 0))
38 ("hufnagel_do3" . ("clefs-hufnagel_do" 3 0))
39 ("hufnagel_fa1" . ("clefs-hufnagel_fa" -1 0))
40 ("hufnagel_fa2" . ("clefs-hufnagel_fa" 1 0))
41 ("hufnagel_do_fa" . ("clefs-hufnagel_do_fa" 4 0))
42 ("mensural_c1" . ("clefs-mensural_c" -2 0))
43 ("mensural_c2" . ("clefs-mensural_c" 0 0))
44 ("mensural_c3" . ("clefs-mensural_c" 2 0))
45 ("mensural_c4" . ("clefs-mensural_c" 4 0))
46 ("mensural_f" . ("clefs-mensural_f" 2 0))
47 ("mensural_g" . ("clefs-mensural_g" -2 0))
48 ("neo_mensural_c1" . ("clefs-neo_mensural_c" -4 0))
49 ("neo_mensural_c2" . ("clefs-neo_mensural_c" -2 0))
50 ("neo_mensural_c3" . ("clefs-neo_mensural_c" 0 0))
51 ("neo_mensural_c4" . ("clefs-neo_mensural_c" 2 0))
52 ("petrucci_c1" . ("clefs-petrucci_c1" -4 0))
53 ("petrucci_c2" . ("clefs-petrucci_c2" -2 0))
54 ("petrucci_c3" . ("clefs-petrucci_c3" 0 0))
55 ("petrucci_c4" . ("clefs-petrucci_c4" 2 0))
56 ("petrucci_c5" . ("clefs-petrucci_c5" 4 0))
57 ("petrucci_f" . ("clefs-petrucci_f" 2 0))
58 ("petrucci_g" . ("clefs-petrucci_g" -2 0))
63 ;; "an alist mapping GLYPHNAME to the position of the central C for that symbol"
64 (define c0-pitch-alist
68 ("clefs-percussion" . 0)
70 ("clefs-vaticana_do" . 0)
71 ("clefs-vaticana_fa" . 4)
72 ("clefs-medicaea_do" . 0)
73 ("clefs-medicaea_fa" . 4)
74 ("clefs-hufnagel_do" . 0)
75 ("clefs-hufnagel_fa" . 4)
76 ("clefs-hufnagel_do_fa" . 0)
77 ("clefs-mensural_c" . 0)
78 ("clefs-mensural_f" . 4)
79 ("clefs-mensural_g" . -4)
80 ("clefs-neo_mensural_c" . 0)
81 ("clefs-petrucci_c1" . 0)
82 ("clefs-petrucci_c2" . 0)
83 ("clefs-petrucci_c3" . 0)
84 ("clefs-petrucci_c4" . 0)
85 ("clefs-petrucci_c5" . 0)
86 ("clefs-petrucci_f" . 4)
87 ("clefs-petrucci_g" . -4)
91 (define-public (make-clef-set cl)
92 "Generate the clef setting commands for a clef with name CL."
93 (define (make-prop-set props)
96 (m (make-music-by-name 'PropertySet))
99 (map (lambda (x) (ly:set-mus-property! m (car x) (cdr x))) props)
106 (l (string-length cl))
110 (if (equal? "8" (substring cl (- l 1) l))
112 (if (equal? "^" (substring cl (- l 2) (- l 1)))
116 (set! cl (substring cl 0 (- l 2)))))
119 (set! e (assoc cl supported-clefs))
124 (musics (map make-prop-set
126 `(((symbol . clefGlyph)
129 ((symbol . centralCPosition)
130 (value . ,(+ oct (caddr e) (cdr (assoc (cadr e) c0-pitch-alist))))
132 ((symbol . clefPosition)
135 ((symbol . clefOctavation)
139 (seq (make-music-by-name 'SequentialMusic))
140 (csp (make-music-by-name 'ContextSpeccedMusic))
143 (ly:set-mus-property! seq 'elements musics)
144 (ly:set-mus-property! csp 'element seq)
145 (ly:set-mus-property! csp 'context-type "Staff")
150 (ly:warn (format "Unknown clef type `~a'
151 See scm/lily.scm for supported clefs" cl))
152 (make-music-by-name 'Music)